3/1/26, 3:55 PM Java String Reference
Tutorials References Exercises Sign In
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO [Link] C
Java String Methods
❮ Previous Next ❯
All String Methods
The String class has a set of built-in methods that you can use on strings.
Method Description Return Type
charAt() Returns the character at the specified index char
(position)
codePointAt() Returns the Unicode of the character at the int
specified index
codePointBefore() Returns the Unicode of the character before int
the specified index
codePointCount() Returns the number of Unicode values found int
in a string.
compareTo() Compares two strings lexicographically int
compareToIgnoreCase() Compares two strings lexicographically, int
ignoring case differences
concat() Appends a string to the end of another string String
contains() Checks whether a string contains a sequence boolean
of characters
contentEquals() Checks whether a string contains the exact boolean
same sequence of characters of the specified
CharSequence or StringBuffer
[Link] 1/6
3/1/26, 3:55 PM Java String Reference
copyValueOf()
Tutorials Returns
References a String thatrepresents the characters
Exercises
of the character array
String Sign In
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO [Link] C
endsWith() Checks whether a string ends with the boolean
specified character(s)
equals() Compares two strings. Returns true if the boolean
strings are equal, and false if not
equalsIgnoreCase() Compares two strings, ignoring case boolean
considerations
format() Returns a formatted string using the specified String
locale, format string, and arguments
getBytes() Converts a string into an array of bytes byte[]
getChars() Copies characters from a string to an array of void
chars
hashCode() Returns the hash code of a string int
indexOf() Returns the position of the first found int
occurrence of specified characters in a string
intern() Returns the canonical representation for the String
string object
isEmpty() Checks whether a string is empty or not boolean
join() Joins one or more strings with a specified String
separator
lastIndexOf() Returns the position of the last found int
occurrence of specified characters in a string
length() Returns the length of a specified string int
matches() Searches a string for a match against a regular boolean
expression, and returns the matches
offsetByCodePoints() Returns the index within this String that is int
offset from the given index by
codePointOffset code points
regionMatches() Tests if two string regions are equal boolean
[Link] 2/6
3/1/26, 3:55 PM Java String Reference
replace()
Tutorials Searches
References a Exercises
string fora specified value, and
returns a new string where the specified
String Sign In
HTML
CSS JAVASCRIPT values
SQLare replaced
PYTHON JAVA PHP HOW TO [Link] C
replaceAll() Replaces each substring of this string that String
matches the given regular expression with the
given replacement
replaceFirst() Replaces the first occurrence of a substring String
that matches the given regular expression
with the given replacement
split() Splits a string into an array of substrings String[]
startsWith() Checks whether a string starts with specified boolean
characters
subSequence() Returns a new character sequence that is a CharSequence
subsequence of this sequence
substring() Returns a new string which is the substring of String
a specified string
toCharArray() Converts this string to a new character array char[]
toLowerCase() Converts a string to lower case letters String
toString() Returns the value of a String object String
toUpperCase() Converts a string to upper case letters String
trim() Removes whitespace from both ends of a String
string
valueOf() Returns the string representation of the String
specified value
REMOVE ADS
Related Pages
Java Strings Tutorial
[Link] 3/6
3/1/26, 3:55 PM Java String Reference
❮ Previous
Tutorials References Sign
in to track progress
Exercises Next ❯ In
Sign
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO [Link] C
15
COLOR PICKER
REMOVE ADS
-->
PLUS SPACES
[Link] 4/6
3/1/26, 3:55 PM Java String Reference
Tutorials References
GET CERTIFIED
Exercises
FOR TEACHERS
Sign In
HTML
CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO [Link] C
BOOTCAMPS CONTACT US
Top Tutorials
HTML Tutorial
CSS Tutorial
JavaScript Tutorial
How To Tutorial
SQL Tutorial
Python Tutorial
[Link] Tutorial
Bootstrap Tutorial
PHP Tutorial
Java Tutorial
C++ Tutorial
jQuery Tutorial
Top References
HTML Reference
CSS Reference
JavaScript Reference
SQL Reference
Python Reference
[Link] Reference
Bootstrap Reference
PHP Reference
HTML Colors
Java Reference
AngularJS Reference
jQuery Reference
Top Examples Get Certified
HTML Examples HTML Certificate
CSS Examples CSS Certificate
JavaScript Examples JavaScript Certificate
How To Examples Front End Certificate
SQL Examples SQL Certificate
Python Examples Python Certificate
[Link] Examples PHP Certificate
Bootstrap Examples jQuery Certificate
PHP Examples Java Certificate
Java Examples C++ Certificate
XML Examples C# Certificate
jQuery Examples XML Certificate
FORUM ABOUT ACADEMY
[Link] 5/6
3/1/26, 3:55 PM Java String Reference
W3Schools is optimized for learning and training. Examples might be simplified to improve reading and
Tutorials References learning.
Exercises
Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full
Sign In
correctness
HTML
of
CSSall content. While
JAVASCRIPTusing W3Schools,
SQL you agree
PYTHONto have read and accepted
JAVA PHP our terms
HOWof use,
[Link] C
and privacy policy.
Copyright 1999-2026 by Refsnes Data. All Rights Reserved. W3Schools is Powered by [Link].
[Link] 6/6