boolean java.lang.String.equals(Object anObject)
equals
public boolean equals(Object anObject)
Compares this string to the specified object. The result is true if and only if the argument is not null and is a String object that represents the same sequence of characters as this object.
Overrides:
equals in class Object
Parameters:
anObject - The object to compare this String against
Returns:
true if the given object represents a String equivalent to this string, false otherwise
当且仅当该参数不为 null
区别就是
"123".equals(null);//false
null..equals("123");//抛 runtime
|