Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
What Is String? | String
Java Basics

What Is String? What Is String?

String and How to Use It

In Java, a "String" is a data type used to represent text. Its syntax looks like this:

java

Main.java

You've already encountered a "String" when you displayed something on the screen using double quotation marks (""). Yes, "String" is among us. A string can also be output like any other variable, for example:

java

Main.java

It looks simple. Well, let's move on to the challenging part then. A string is a data type that cannot be changed after initialization. This is called an immutable class. Don't get stuck on these intimidating words right now; we will discuss them in a separate course. We can directly modify the value of an already initialized string variable, but in doing so, we simply create a new object in memory. For example:

java

Main.java

We can also create arrays of strings:

java

Main.java

In the next chapter, we will delve into the fundamental methods for working with strings, and you will come to understand why I mentioned that the value of a string variable cannot be altered without specific operations.

1. Will the following code compile?
2. Can we create an array of ``String`` data type?

Will the following code compile?

Select the correct answer

Can we create an array of String data type?

Select the correct answer

Everything was clear?

Section 5. Chapter 1
course content

Course Content

Java Basics

What Is String? What Is String?

String and How to Use It

In Java, a "String" is a data type used to represent text. Its syntax looks like this:

java

Main.java

You've already encountered a "String" when you displayed something on the screen using double quotation marks (""). Yes, "String" is among us. A string can also be output like any other variable, for example:

java

Main.java

It looks simple. Well, let's move on to the challenging part then. A string is a data type that cannot be changed after initialization. This is called an immutable class. Don't get stuck on these intimidating words right now; we will discuss them in a separate course. We can directly modify the value of an already initialized string variable, but in doing so, we simply create a new object in memory. For example:

java

Main.java

We can also create arrays of strings:

java

Main.java

In the next chapter, we will delve into the fundamental methods for working with strings, and you will come to understand why I mentioned that the value of a string variable cannot be altered without specific operations.

1. Will the following code compile?
2. Can we create an array of ``String`` data type?

Will the following code compile?

Select the correct answer

Can we create an array of String data type?

Select the correct answer

Everything was clear?

Section 5. Chapter 1
some-alt