5. compareTo()

Compares two strings lexicographically. The comparison is based on the Unicode value of each character in the strings. This method returns a positive/negative integer. If an exact match is found then this method will return 0. Note that this method is case-sensitive.

6. compareToIgnoreCase()

This method also compares the two strings like the above compareTo method but this method is not case sensitive. It means both “abc” and “ABC” comparison will return ‘0’.

7. concat()

This method is used to concatenate two strings into one string.

8. contains()

This method will check if the string contains any character specified. It returns true or false based on the match found. This method is also case-sensitive.

9. contentEquals()

It checks if the string contains the specified character sequence. It returns true/false based on the if character sequence is matching or not.

String class Methods

Related Posts