/* String is a build-in class in java, Yes It's a class, but it is
almost used like any other data types such as int, float, long, etc.
Similar we can use String also. */
What is String ?
String is a collection of characters that are forming from words or sentences.
String object must be in a double quotes.
Simplest way to creating a String -->
String str1 = "This is a String literal";
Explanation :
String - is a build-in class provided by java.
str1 - is a variable, means variable of type of object is called the reference,
however it is most called reference. Hold the String object or point
to the String object.
"This is a String" - is a String literal and created in String pool.
/*A Java string is a sequence of characters that exists as an object of the class java. lang.
Java strings are created and manipulated through the string class.
Once created, a string is immutable -- its value cannot be changed. A string is sequence of characters.*/
String str = "This is a String":
String str2 = "Hello World";
class Main {
public static void main(String[] args) {
// create strings
String first = "Java";
String second = "Python";
String third = "JavaScript";
// print strings
System.out.println(first); // print Java
System.out.println(second); // print Python
System.out.println(third); // print JavaScript
}
}
/* String is a build-in class in java, Yes It's a class, but it is
almost used like any other data types such as int, float, long, etc.
Similar we can use String also. */
What is String ?
String is a collection of characters that are forming from words or sentences.
String object must be in a double quotes.
Simplest way to creating a String -->
String str1 = "This is a String literal";
Explanation :
String - is a build-in class provided by java.
str1 - is a variable, means variable of type of object is called the reference,
however it is most called reference. Hold the String object or point
to the String object.
"This is a String" - is a String literal and created in String pool.
/* String is a build-in class in java, Yes It's a class, but it is
almost used like any other data types such as int, float, long, etc.
Similar we can use String also. */
What is String ?
String is a collection of characters that are forming from words or sentences.
String object must be in a double quotes.
Simplest way to creating a String -->
String str1 = "This is a String literal";
Explanation :
String - is a build-in class provided by java.
str1 - is a variable, means variable of type of object is called the reference,
however it is most called reference. Hold the String object or point
to the String object.
"This is a String" - is a String literal and created in String pool.