当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Scala String equalsIgnoreCase()用法及代码示例


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

函数定义: Boolean equalsIgnoreCase(String anotherString)
返回类型: It returns true if the string is same as the object stated by ignoring the case difference, else it returns false.

范例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


相关用法


注:本文由纯净天空筛选整理自nidhi1352singh大神的英文原创作品 Scala String equalsIgnoreCase() method with example。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。