String Class Methods List
Here is a list of some commonly used methods of the String class:
length(): Returns the length of the string.
charAt(int index): Returns the character at the specified index.
substring(int beginIndex, int endIndex): Returns a new string that is a substring of this string.
concat(String str): Concatenates the specified string to the end of this string.
equals(Object obj): Compares this string to the specified object for equality.
compareTo(String anotherString): Compares this string to another string.
toLowerCase(): Converts all of the characters in this string to lower case.
toUpperCase(): Converts all of the characters in this string to upper case.
trim(): Returns a new string that is a copy of this string with leading and trailing white space removed.
indexOf(int ch): Returns the index within this string of the first occurrence of the specified character.
lastIndexOf(int ch): Returns the index within this string of the last occurrence of the specified character.
contains(CharSequence s): Returns true if this string contains the specified sequence of char values.
replace(char oldChar, char newChar): Returns a new string resulting from replacing all occurrences of oldChar in this string with newChar.
startsWith(String prefix): Tests if this string starts with the specified prefix.
endsWith(String suffix): Tests if this string ends with the specified suffix.
split(String regex): Splits this string around matches of the given regular expression.
toCharArray(): Converts this string to a new character array.
valueOf(int i): Returns the string representation of the int argument.
format(String format, Object... args): Returns a formatted string using the specified format string and arguments.
isEmpty(): Returns true if this string is empty.
These methods can be used to manipulate and extract information from strings in various ways. Some methods are used for simple operations such as finding the length of a string, while others are used for more complex operations such as searching for and replacing substrings within a string.