0% found this document useful (0 votes)
5 views1 page

Java String Methods Summary

Uploaded by

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

Java String Methods Summary

Uploaded by

abdulrahmanr861
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Java String Methods Summary

Length & Indexing Methods:


- length(): Get the length of the string.
- charAt(): Access character at specific index.
- indexOf(): Find the first occurrence of a character or substring.
- lastIndexOf(): Find the last occurrence.

Comparison Methods:
- equals(): Check if two strings are exactly equal.
- equalsIgnoreCase(): Check if equal ignoring case.
- compareTo(): Compare strings lexicographically.
- startsWith(): Check if string starts with prefix.
- endsWith(): Check if string ends with suffix.
- contains(): Check if substring exists.

Transformation Methods:
- toUpperCase(): Convert to uppercase.
- toLowerCase(): Convert to lowercase.
- trim(): Remove leading/trailing spaces.
- replace(): Replace characters or substrings.
- substring(): Extract a portion of the string.
- format(): Format strings using placeholders.

Splitting & Checking Methods:


- split(): Split into parts by a regex.
- isEmpty(): Check if the string is empty.

Conversion Method:
- valueOf(): Convert other data types into strings.

You might also like