equals - When is it appropriate to use reference equality vs object equality in Java? -
i understand different between these 2 terms , methods use if wanted check if 2 objects had references or same value. question is, when ever have check if 2 objects have same reference opposed checking if 2 objects have same content or value(there has never been time i've had check if 2 objects have reference)?
that's not "instead of" equality check, reference check before equality check performance , null-safety reasons.
in effect, happens when call objects.equals(a,b)
instead of a.equals(b)
.
public static boolean equals(object a, object b) { return (a == b) || (a != null && a.equals(b)); }
Comments
Post a Comment