Why are these == but not `equals()`?
(small) Integer instances are cached, so the invariant x == y is holded for small instances (actually -127 +128, depends on JVM): Integer a = 10; Integer b = 10; assert(a == b); // ok, same instance reused a = 1024; b = 1024; assert(a == b); // fail, not the same instance…. assert(a.equals(b)); // … Read more