Java String Functions - Complete Reference
length()
Returns the length of the string.
charAt(int index)
Returns the character at the specified index.
substring(int beginIndex)
Returns a substring from beginIndex to end.
substring(int beginIndex, int endIndex)
Returns a substring between beginIndex and endIndex.
equals(Object another)
Compares the content of strings.
equalsIgnoreCase(String another)
Compares strings ignoring case.
compareTo(String another)
Compares two strings lexicographically.
toLowerCase()
Converts all characters to lowercase.
toUpperCase()
Converts all characters to uppercase.
trim()
Removes whitespace from beginning and end.
replace(char old, char new)
Replaces all old characters with new.
contains(CharSequence s)
Checks if string contains the specified sequence.
indexOf(int ch)
Returns index of first occurrence of character.
lastIndexOf(int ch)
Returns index of last occurrence of character.
startsWith(String prefix)
Checks if string starts with the specified prefix.
endsWith(String suffix)
Checks if string ends with the specified suffix.
split(String regex)
Splits the string around matches of the regex.
isEmpty()
Checks if the string is empty.
join(CharSequence delimiter, CharSequence... elements)
Joins the strings with a delimiter.
valueOf(primitive data type)
Converts data type to string.