String methods – contentEquals

ContentEquals() is used to compare the string. It has 2 types of implementations.

  1. boolean contentEquals(CharSequence cs)
  2. boolean contentEquals(StringBuffer sb)

Let’s understand them with the help of examples.

boolean contentEquals(CharSequence cs):

Returns true if string matches with the specified sequence of characters, else returns false.

Output:
true
false

 

boolean contentEquals(StringBuffer sb):

This method compares the String with String buffer. If both matches returns true, else return false.

Output:
true
false
Ask Question
Have any question or suggestion for us?Please feel free to post in Q&A Forum
Print Friendly, PDF & Email
String methods - startsWith and endsWith
String methods - getBytes() and getChars()
Shekhar Sharma

Shekhar Sharma

Shekhar Sharma is founder of testingpool.com. He is an automation engineer having more than 8 years of experience who loves troubleshooting in automation and finding innovative ways to solve the problems. His other leisurely activities includes playing harmonica, paintings, sketching portrait, watching movies and travelling etc.

You may also like...