📌  相关文章
📜  带有示例的 Scala String contentEquals() 方法

📅  最后修改于: 2022-05-13 01:54:36.200000             🧑  作者: Mango

带有示例的 Scala String contentEquals() 方法

contentEquals()方法用于将字符串与StringBuffer的内容进行比较。

示例 #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)
      
    }
} 
输出:
true

示例 #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)
      
    }
} 
输出:
false