Java equalsIgnoreCase() 方法
如果给定对象与字符串相等,则返回 true;否则返回 false。
public class Test {
public static void main(String args[]) {
String Str1 = new String("runoob");
String Str2 = Str1;
String Str3 = new String("runoob");
String Str4 = new String("RUNOOB");
boolean retVal;
retVal = Str1.equals( Str2 );
System.out.println("返回值 = " + retVal );
retVal = Str3.equals( Str4);
System.out.println("返回值 = " + retVal );
retVal = Str1.equalsIgnoreCase( Str4 );
System.out.println("返回值 = " + retVal );
}
}
返回值 = true
返回值 = false
返回值 = true