The equals
method in AtomicInteger
and AtomicLong
returns true
only if two instances are
identical, not if they represent the same number value.
This is because equals
is not part of the API contract of these classes, and they do not override the method inherited from
java.lang.Object
. Although both classes implement the Number
interface, assertions about equals
comparing
number values are not part of that interface either. Only the API contract of implementing classes like Integer
, Long
,
Float
, BigInteger
, etc., provides such assertions.