Home >>Java String Methods

Java String Methods

Java String Methods

There are various Java string methods that are present in the Java strings and are used for different usage of theirs and that can be used in the strings. These methods are generally built-in sets in the strings in Java. Here are some of the string functions that are depicted below along with their return type and a short description:

Method Description Return Type
charAt() This Java String method is generally used to return the character at the specified index or position. char
codePointAt() This Java String method is generally used to return the Unicode of the character at the specified index. int
codePointBefore() This Java String method is generally used to return the Unicode of the character before the specified index. int
codePointCount() This Java String method is generally used to return the Unicode in the specified text range of this String. int
compareTo() This Java String method is generally used to compares two strings lexicographically. int
compareToIgnoreCase() This Java String method is generally used to compares two strings lexicographically while ignoring the case differences. int
concat() This Java String method is generally used to append a string to the end of another string. String
contains() This Java String method is generally used to check whether a string contains a sequence of characters boolean
contentEquals() This Java String method is generally used to check whether a string contains the exact same sequence of characters of the specified CharSequence or StringBuffer boolean
copyValueOf() This Java String method is generally used to return a String representing the characters of the character array String
endsWith() This Java String method is generally used to check whether a string ends with the specified character(s) boolean
equals() This Java String method is generally used to compare two strings and it returns true if the strings are found to be equal, and false if that is not the case. boolean
equalsIgnoreCase() This Java String method is generally used to compare two strings and at the same time ignore the case considerations. boolean
format() This Java String method is generally used to return a formatted string by using the specified locale, format string, and the arguments. String
getBytes() This Java String method is generally used to encode this very String into a sequence of bytes by using the named charset and it stores the result into a new byte array. byte[]
getChars() This Java String method is generally used to copy the characters from a string to an array of the chars. void
hashCode() This Java String method is generally used to return the hash code of a string. int
indexOf() This Java String method is generally used to return the position of the first found occurrence of the specified characters in a string. int
intern() This Java String method is generally used to return the index that is within this string of the first occurrence of a specified character that results in starting of the search at the specified index. String
isEmpty() This Java String method is generally used to check whether a string is empty or not. boolean
lastIndexOf() This Java String method is generally used to return the position of the last found occurrence of the specified characters in a string. int
length() This Java String method is generally used to return the length of a specified string. int
matches() This Java String method is generally used to search for a string that is for a match against a regular expression and after doing so it returns the matches. boolean
offsetByCodePoints() This Java String method is generally used to return the index within this String that is basically offset from the given index by codePointOffset code points. int
regionMatches() This Java String method is generally used to test if the two string regions are equal or not. boolean
replace() This Java String method is generally used to search for a string that has a specified value and it returns a new string where the specified values are already replaced. String
replaceFirst() This Java String method is generally used to replace the first occurrence of a substring that basically matches the provided regular expression with the provided replacement. String
replaceAll() This Java String method is generally used to replace each of the substring of this string that basically matches the provided regular expression with the provided replacement. String
split() This Java String method is generally used to split a string into an array of substrings. String[]
startsWith() This Java String method is generally used to check whether a string starts with the specified characters or not. boolean
subSequence() This Java String method is generally used to return a new character sequence that is a subsequence of this sequence. CharSequence
substring() This Java String method is generally used to extract the characters from a string, through the specified number of character, and beginning at a specified start position. String
toCharArray() This Java String method is generally used to convert this string to a new character array. char[]
toLowerCase() This Java String method is generally used to convert a string to lower case letters. String
toString() This Java String method is generally used to return the value of a String object. String
toUpperCase() This Java String method is generally used to convert a string to the upper case letters. String
trim() This Java String method is generally used to remove the whitespace from both of the ends of a string. String
valueOf() This Java String method is generally used to return the primitive value of a String object. String

Java String Methods Index

Sr.No. Topics
1 Java String charAt() method
2 Java String compareTo() method
3 Java String concat() method
4 Java String contains() method
5 Java String codePointAt() Method
6 Java String codePointBefore() Method
7 Java String codePointCount() Method
8 Java String compareToIgnoreCase() Method
9 Java String contentEquals() Method
10 Java String copyValueOf() Method
11 Java String endsWith() method
12 Java String equals() method
13 Java String equalsIgnoreCase() method
14 Java String format() method
15 Java String getBytes() method
16 Java String getChars() method
17 Java String hashCode() Method
18 Java String indexOf() Method
19 Java String intern() method
20 Java String isEmpty() Method
21 Java String lastIndexOf() Method
22 Java String length() Method
23 Java String replace() Method
24 Java String replaceAll() method
25 Java String split() method
26 Java String startsWith() Method
27 Java String substring() Method
28 Java String toCharArray() Method
29 Java String toLowerCase() Method
30 Java String toUpperCase() Method
31 Java String trim() Method
32 Java String valueOf() Method