contentEquals() - String Methods in Java

This article is a part of String Methods in Java.
The contentEquals() method searches for the exact specified sequence of characters or StringBuffer in the string. Basically, it compares the specified parameters with the String. The parameters passed can be of CharSequence or StringBuffer type.

Return type

The return type for contentEquals() is Boolean. It returns true if the specified parameter exists in the string and false otherwise.
Let us look at an example code to understand this method.



Let us look at the output of the above example code.

String Methods contentEquals()
Fig.1- String Method - contentEquals()

Here barring the second string “LearningJournal,” both the strings are not exactly alike the given string.

Read More

Author : Satyam Kumar -

You will also like: