bugl
bugl
HomeLearnPatternsPathsSearch
HomeLearnPatternsPathsSearch

Loading lesson path

Learn/Java/Java Reference
Java•Java Reference

Java String Methods

Flash cards

Review the key moves

1/3
Core idea

What is the main idea behind Java String Methods?

Lesson checks

Practice each idea before moving on

Short Mimo-style checks built from this lesson's code, terms, and sequence.

1Quick choice

Which statement best captures the main point of this lesson?

All String Methods

The String class has a set of built-in methods that you can use on strings.

MethodDescriptionReturn Type
charAt()Returns the character at the specified index (position)char
codePointAt()Returns the Unicode of the character at the specified indexint
codePointBefore()Returns the Unicode of the character before the specified indexint
codePointCount()Returns the number of Unicode values found in a string.int
compareTo()Compares two strings lexicographicallyint
compareToIgnoreCase()Compares two strings lexicographically, ignoring case differencesint
concat()Appends a string to the end of another stringString
contains()Checks whether a string contains a sequence of charactersboolean
contentEquals()Checks whether a string contains the exact same sequence of characters of the specified CharSequence or StringBufferboolean
copyValueOf()Returns a String that represents the characters of the character arrayString
endsWith()Checks whether a string ends with the specified character(s)boolean
equals()Compares two strings. Returns true if the strings are equal, and false if notboolean
equalsIgnoreCase()Compares two strings, ignoring case considerationsboolean
format()Returns a formatted string using the specified locale, format string, and argumentsString
getBytes()Converts a string into an array of bytesbyte[]
getChars()Copies characters from a string to an array of charsvoid
hashCode()Returns the hash code of a stringint
indexOf()Returns the position of the first found occurrence of specified characters in a stringint
intern()Returns the canonical representation for the string objectString
isEmpty()Checks whether a string is empty or notboolean
join()Joins one or more strings with a specified separatorString
lastIndexOf()Returns the position of the last found occurrence of specified characters in a stringint
length()Returns the length of a specified stringint
matches()Searches a string for a match against a regular expression, and returns the matchesboolean
offsetByCodePoints()Returns the index within this String that is offset from the given index by codePointOffset code pointsint
regionMatches()Tests if two string regions are equalboolean
replace()Searches a string for a specified value, and returns a new string where the specified values are replacedString
replaceAll()Replaces each substring of this string that matches the given regular expression with the given replacementString
replaceFirst()Replaces the first occurrence of a substring that matches the given regular expression with the given replacementString
split()Splits a string into an array of substringsString[]
startsWith()Checks whether a string starts with specified charactersboolean
subSequence()Returns a new character sequence that is a subsequence of this sequenceCharSequence
substring()Returns a new string which is the substring of a specified stringString
toCharArray()Converts this string to a new character arraychar[]
toLowerCase()Converts a string to lower case lettersString
toString()Returns the value of a String objectString
toUpperCase()Converts a string to upper case lettersString
trim()Removes whitespace from both ends of a stringString
valueOf()Returns the string representation of the specified valueString

Previous

Java while Keyword

Next

Java String charAt() Method