English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Java Basic Tutorial

Java Flow Control

Java Array

Java Object-Oriented (I)

Java Object-Oriented (II)

Java Object-Oriented (III)

Java Exception Handling

Java List (List)

Java Queue (Queue)

Java Map Collection

Java Set Collection

Java Input/Output (I/O)/O)

Java Reader/Writer

Java Other Topics

Java String (String) Method Overview

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

MethodDescription
split()Splits the string into an array of substrings based on the specified delimiter (regular expression)
compareTo()Compares two strings in dictionary order
compareToIgnoreCase()Compares two strings, ignoring case
length()Returns the length of the string
replace()Replaces all occurrences of the specified character in the string/Text
replaceAll()Replaces all occurrences of the substring that match the regular expression pattern
substring()Returns a substring of the given string
equals()Compares two strings
equalsIgnoreCase()Compares two strings, ignoring case
contains()Checks if the string contains the specified substring
indexOf()Returns the specified character from the string/The index of the first occurrence of the substring.
trim()Removes any leading and trailing spaces
charAt()Returns the character at the specified index
toLowerCase()Convert the characters in the string to lowercase
concat()Concatenate two strings and return
valueOf()Return the string representation of the value
matches()Check if the string matches the given regular expression
startsWith()Check if the string starts with the given string
endsWith()Check if the string ends with the given string
isEmpty()Check if the string is empty
intern()Return the normalized representation of the string
getBytes()Encode the string into a byte sequence
contentEquals()Check if the string is equal to charSequence (character sequence)
hashCode()Return the hash code of the string
join()Join the given strings using a delimiter
replaceFirst()Replace the first matching substring
subSequence()Return a substring of the string
toCharArray()Convert a string to a char array
format()Return a formatted string