String stringName = "your string content";
String newString = new String("Hello World");
/*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 a string using new
String name = new String("Java String");
System.out.println(name); // print Java String
}
}
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
}
}
// create a string using the new keyword
String name = new String("Java String");