> Objects, by contrast, are resistant to this kind of optimization because they have an identity distinct from their value. This is what .equals() tests for: the object’s location in memory.
AFAIK equals() test for equality not identity in Java.
AFAIK equals() test for equality not identity in Java.
In an ideal world, == would test for equality. In a worse world, equals() would test for equality. But we live in a Java world: Equals() is predefined as an identity check on Objects, and it's up invididual implementations to override that check with something better.
> Object identity is a good default