The contentEquals() method is utilized to compare a string to the content of StringBuffer.
Method Definition: Boolean contentEquals(StringBuffer sb)
Return Type: It returns true if the content is equal to the stated string else it returns false.
Example #1:
// Scala program of contentEquals() // method // Creating object object GfG { // Main method def main(args:Array[String]) { // Creating a StringBuffer val m1=new StringBuffer("Nidhi") // Applying contentEquals() method val result = "Nidhi".contentEquals(m1) // Displays output println(result) } } |
chevron_right
filter_none
Output:
true
Example #2:
// Scala program of contentEquals() // method // Creating object object GfG { // Main method def main(args:Array[String]) { // Creating a StringBuffer val m1=new StringBuffer("Nidhi") // Applying contentEquals() method val result = "nidhi".contentEquals(m1) // Displays output println(result) } } |
chevron_right
filter_none
Output:
false
Recommended Posts:
- Scala String regionMatches(int toffset, String other, int offset, int len) method with example
- Scala String startsWith(String prefix, int toffset) method with example
- Scala String split(String regex, int limit) method with example
- Scala String indexOf(String str, int fromIndex) method with example
- Scala String startsWith(String prefix) method with example
- Scala String lastIndexOf(String str, int fromIndex) method with example
- Scala String lastIndexOf(String str) method with example
- Scala String indexOf(String str) method with example
- Scala Int +(x: String) method with example
- Scala String matches() method with example
- Scala String lastIndexOf() method with example
- Scala String intern() method with example
- Scala String regionMatches() method with example
- Scala String subSequence() method with example
- Scala String replace() method with example
- Scala String replaceFirst() method with example
- Scala String replaceAll() method with example
- Scala String trim() method with example
- Scala String toUpperCase() method with example
- Scala String charAt() method with example
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

