Java字符串equals()方法。
该equals()方法将该字符串与指定对象进行比较。当且仅当参数不为null并且是一个String对象,表示与此对象相同的字符序列时,结果为true。
示例
public class Sample{
public static void main(String []args){
String s1 = "nhooo";
String s2 = "nhooo";
String s3 = new String ("nhooo.com");
System.out.println(s1.equals(s2));
System.out.println(s2.equals(s3));
}
}输出结果
true false