此方法将此String与另一个String进行比较,而忽略大小写考虑。
boolean equalsIgnoreCase - 语法
public boolean equalsIgnoreCase(String anotherString)
这是参数的详细信息-
anotherString - 与该字符串进行比较的字符串。
boolean equalsIgnoreCase - 返回值
如果参数不为null并且字符串相等,则此方法返回true,忽略大小写;否则为false。
boolean equalsIgnoreCase - 示例
public class Test { public static void main(String args[]) { String Str1=new String("This is really not immutable!!"); String Str2=Str1; String Str3=new String("This is really not immutable!!"); String Str4=new String("This IS REALLY NOT IMMUTABLE!!"); boolean retVal; retVal=Str1.equals( Str2 ); System.out.println("Returned Value=" + retVal ); retVal=Str1.equals( Str3 ); System.out.println("Returned Value=" + retVal ); retVal=Str1.equalsIgnoreCase( Str4 ); System.out.println("Returned Value=" + retVal ); } }
这将产生以下输出-
Returned Value=true Returned Value=true Returned Value=true
参考链接
https://www.learnfk.com/java/java-string-equalsignorecase.html
标签:Java,String,无涯,Value,equalsIgnoreCase,boolean,retVal,Returned From: https://blog.51cto.com/u_14033984/8850158