📜  带有示例的 Scala String equalsIgnoreCase() 方法

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

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

equalsIgnoreCase()方法用于通过忽略大小写差异来检查所述字符串和对象是否相等。

示例 #1:

// Scala program of equalsIgnoreCase()
// method
  
// Creating object
object GfG
{ 
  
    // Main method
    def main(args:Array[String])
    {
        // Creating an array
        val m1 = Array('N', 'i', 'd', 'h', 'i')
          
          
        // Applying equalsIgnoreCase() method
        val result = "Nidhi".equalsIgnoreCase("Nidhi")
          
        // Displays output
        println(result)
      
    }
} 
输出:
true

示例 #2:

// Scala program of equalsIgnoreCase()
// method
  
// Creating object
object GfG
{ 
  
    // Main method
    def main(args:Array[String])
    {
        // Creating an array
        val m1 = Array('N', 'i', 'd', 'h', 'i')
          
          
        // Applying equalsIgnoreCase() method
        val result = "Nidhi".equalsIgnoreCase("nidhi")
          
        // Displays output
        println(result)
      
    }
} 
输出:
true