.contentEquals()
Published Jul 26, 2021Updated Sep 3, 2021
Contribute to Docs
Returns true
if the sequence of characters in the string is equal to the content of the specified string. If not, returns false
.
Syntax
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";System.out.println(word.contentEquals("water"));System.out.println(word.contentEquals("watermelon"));// Output: false// Output: true}}
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn Java on Codecademy
- Career path
Computer Science
Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!Includes 6 CoursesWith Professional CertificationBeginner Friendly75 hours - Free course
Learn Java
Learn to code in Java — a robust programming language used to create software, web and mobile apps, and more.Beginner Friendly16 hours