There are two ways to create the String object, by string literal and by new keyword.
It’s not a primitive data type like int and long. String class represents character Strings. String is used in almost all the Java applications and there are some interesting facts we should know about String. String in immutable and final in Java and JVM uses String Pool to store all the String objects.
To make Java more memory efficient (because no new objects are created if it exists already in string constant pool).
String is an immutable object. StringBuffer is a mutable object.
The toString() method returns the string representation of any object. If you print any object, java compiler internally invokes the toString() method on the object. So overriding the toString() method, returns the desired output, it can be the state of an object etc. depends on your implementation.
charAt(int), replace(String,String), split(String), equals(String), equalsIgnoreCase(String), startsWith(String), endsWith(String) etc.
length(), capacity(), setLength(int), append(String), reverse() etc.
Only one object will be created and this object will be stored in the string constant pool.
Using toCharArray() method.