

It returns true if two strings are equal and false if not. These methods compare the value of string to check if two strings are equal or not. String class provides equals() and equalsIgnoreCase() methods to compare two strings. There are several constructors available in String class to get String from char array, byte array, StringBuffer and StringBuilder. We can create String object using new operator, just like any normal java class.

If found, it just returns the reference to that String object else it creates a new String object with given value and stores it in the String pool. When we create a String using double quotes, JVM looks in the String pool to find if any other String is stored with same value. In this case a string literal is enclosed with double quotes. This is the most common way of creating string. There are many ways to create a string object in java, some of the popular ones are given below. Let’s go ahead and learn more about Java String class. Java provides two useful classes for String manipulation - StringBuffer and StringBuilder.We can concat two strings using + operator. String is the only class where operator overloading is supported in java.String is immutable object which means that it cannot be changed once it is created.When we create a string in java, it actually creates an object of type String.Basically, string is a sequence of characters but it’s not a primitive type.Java String class is defined in java.lang package. Java String is one of the most widely used class.
