The Wayback Machine - https://web.archive.org/web/20240118172841/https://www.geeksforgeeks.org/scala-string-contentequals-method-with-example/
Open In App
Related Articles

Scala String contentEquals() method with example

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report

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)
      
    }
} 


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)
      
    }
} 


Output:

false

Learn to code easily with our course Coding for Everyone. This course is accessible and designed for everyone, even if you're new to coding. Start today and join millions on a journey to improve your skills!

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Commit to GfG's Three-90 Challenge! Purchase a course, complete 90% in 90 days, and save 90% cost click here to explore.
Last Updated : 03 Oct, 2019
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads