带有示例的 Scala String equalsIgnoreCase() 方法
equalsIgnoreCase()方法用于通过忽略大小写差异来检查所述字符串和对象是否相等。
Method Definition: Boolean equalsIgnoreCase(String anotherString)
Return Type: 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