Returns true if the sequence of characters in the string is equal to the content of the specified string. If not, returns false.


string.contentEquals(CharSequence characters)
  • characters (required): A character value specifies the sequence of characters to be searched for.

Example 1

Call the .contentEquals() method on the word string with the arguments "water" and "watermelon":

class isContentEqual {
public static void main(String[] args) {
String word = "watermelon";
// Output: false
// Output: true

All contributors

Looking to contribute?

Learn Java on Codecademy