What is String Class Methods Java?
In Java, the String
class provides several methods for string manipulation. Key methods include:
length()
: Returns the length of the string.charAt(int index)
: Returns the character at the specified index.substring(int beginIndex, int endIndex)
: Extracts a portion of the string.indexOf(String str)
: Finds the index of a substring.toLowerCase()
,toUpperCase()
: Converts the string to lower or upper case.trim()
: Removes leading and trailing whitespace.equals(Object obj)
: Compares two strings for equality.concat(String str)
: Appends the specified string.
These methods facilitate various string operations.