Java String Methods | Programiz D11 Phase 2 Skip to main content

Java String Methods

Java has a lot of String methods that allow us to work with strings. In this reference page, you will find all the string methods available in Java. For example, if you need to find the length of a string, use the length() method.

Splits the string at the specified string (regex)

Compares two strings in the dictionary order

Compares two strings ignoring case differences

Returns the length of the string

Replace all matching characters/text in the string

Replace all substrings matching the regex pattern

Returns a substring from the given string

Compares two strings

Compares two strings ignoring case differences

Checks whether the string contains a substring

Returns the index of the character/substring

Removes any leading and trailing whitespace

Returns the character at the given index

Converts characters in the string to lower case

Concatenates two strings and returns it

Returns the string representation of a value

checks whether the string matches the given regex

Checks if the string begins with the given string

Checks if the string ends with the given string

Checks whether a string is empty or not

Returns a canonical representation of the string

Encodes the string into a sequences of bytes

Checks whether the string is equal to charSequence

Returns a hash code for the string

Joins the given strings using the delimiter

Replace the first matching substring

Returns a subsequence from the string

Converts the string to a char array

Returns a formatted string