Java Reference
In-Depth Information
Objects
implementsthenull-tolerant
compare()
methodtofirstcompareitsar-
guments for object identity by using
==
before calling the provided
Comparator
.
The
equals()
and
deepEquals()
methods define equivalence relations over
object references. Unlike
Object.equals(Object o)
,
Ob-
jects.equals(Object a, Object b)
handlesnullvalues,returningtruewhen
bothargumentsarenull,orwhenthefirstargumentisnonnulland
a.equals(b)
re-
turns true.
The
deepEquals()
method is used in the context of arrays (including nested ar-
rays)todetermineiftwoarraysare
deeply equal
(theyarebothnullortheycontainthe
samenumberofelementsandallcorrespondingpairsofelementsinthetwoarraysare
deeply equal).