String Methods
1. length()
length()Method Signature
int length()Description
Example
String text = "Hello, World!";
int length = text.length(); // length will be 132. charAt(int index)
charAt(int index)Method Signature
char charAt(int index)Description
Example
3. substring(int beginIndex)
substring(int beginIndex)Method Signature
Description
Example
4. substring(int beginIndex, int endIndex)
substring(int beginIndex, int endIndex)Method Signature
Description
Example
5. concat(String str)
concat(String str)Method Signature
Description
Example
6. equals(Object obj)
equals(Object obj)Method Signature
Description
Example
7. equalsIgnoreCase(String anotherString)
equalsIgnoreCase(String anotherString)Method Signature
Description
Example
8. startsWith(String prefix)
startsWith(String prefix)Method Signature
Description
Example
9. endsWith(String suffix)
endsWith(String suffix)Method Signature
Description
Example
10. contains(CharSequence sequence)
contains(CharSequence sequence)Method Signature
Description
Example
11. replace(CharSequence target, CharSequence replacement)
replace(CharSequence target, CharSequence replacement)Method Signature
Description
Example
12. trim()
trim()Method Signature
Description
Example
13. split(String regex)
split(String regex)Method Signature
Description
Example
14. toUpperCase() and toLowerCase()
toUpperCase() and toLowerCase()Method Signature
Description
Example
15. isEmpty()
isEmpty()Method Signature
Description
Example
Last updated