[Go to site: main page, start]

0% found this document useful (0 votes)
20 views3 pages

Comprehensive Guide to String Methods

The document provides a comprehensive list of built-in methods available in the String class, detailing their descriptions and return types. Each method serves various functions such as comparing, modifying, and retrieving information from strings. It serves as a reference for developers working with string manipulation in Java.

Uploaded by

G. Netpryse
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views3 pages

Comprehensive Guide to String Methods

The document provides a comprehensive list of built-in methods available in the String class, detailing their descriptions and return types. Each method serves various functions such as comparing, modifying, and retrieving information from strings. It serves as a reference for developers working with string manipulation in Java.

Uploaded by

G. Netpryse
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

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

codePointBefo Returns the Unicode of the character before int


re() the specified index

codePointCou Returns the number of Unicode values found int


nt() in a string.

compareTo() Compares two strings lexicographically int

compareToIgn Compares two strings lexicographically, int


oreCase() ignoring case differences

concat() Appends a string to the end of another string String

contains() Checks whether a string contains a boolean


sequence of characters

contentEquals Checks whether a string contains the exact boolean


() same sequence of characters of the
specified CharSequence or StringBuffer

copyValueOf() Returns a String that represents the String


characters of the character array

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

equalsIgnoreC Compares two strings, ignoring case boolean


ase() considerations

format() Returns a formatted string using the String


specified locale, format string, and
arguments

getBytes() Converts a string into an array of bytes byte[]

getChars() Copies characters from a string to an array void


of 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 boolean


regular expression, and returns the matches

offsetByCodeP Returns the index within this String that is int


oints() offset from the given index by
codePointOffset code points

regionMatche Tests if two string regions are equal boolean


s()

replace() Searches a string for a specified value, and String


returns a new string where the specified
values are replaced

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 CharSequ


) subsequence of this sequence ence

substring() Returns a new string which is the substring String


of 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

Related Pages
Java Strings Tutorial

You might also like