As we know that string is an object that represents the collections of character. String is used for storing the text and if you want to store a text into a string variable then put the text inside the double-quotes.
String in Java is immutable which means it can not be changed when once it has been created. It is a non-primitive data type because it’s size is not fixed.
String is a class that contains lot of methods to performs operation on string such as toUpperCase(), toLowerCase(), isEmpty(), concat(), replace(), length() etc.
Java String Methods
1. toUpperCase(): By using this method we can convert the string to uppercase string.
2. toLowerCase(): By using this method we can convert the string to lowercase string.
3. isEmpty(): This method returns true if the given string has 0 length and return false when the length of the string is greater than.
4. concat(String str): contact the string at the end of the string.
5. replace(char old, char new): It returns the new string after replacing the old value with a new value.
6. length(): This method return the length of the string.
7. toCharArray(): By using this method we convert the string to character array.
8. equals(): use to compare two string, It returns true if the string is equal else return false.
9. equalsIgnoreCase(String string): This method also used to compare two string but it does not consider the case while comparing strings.
10. hashCode(): This method return the hash code of a string.
11. indexOf(): This method returns the position of character from a string.
12. substring(int startindex): It returns the substring starting from the startindex from the string.
13. contains(): It returns the true if the character is found in the string else return false.
14. chartAt(int index): It returns the character at the specified index.
15. split(): This method returns a string array when will matching regex.