It turns out == does not delegate to equals(), it delegates to compareTo. So == will return true if a.compareTo(b) returns 0
So in this particular case
new Integer(1).compareTo(new Long(1)) == 0
so therefore:
new Integer(1) == new Long(1)
but this does not necessarily mean that
new Integer(1).equals(new Long(1))
The reason why this is all so weird and confusing is because the contract of Comparable does not require that it is consistent with equals, though it is strongly recommended.
It is strongly recommended (though not required) that natural orderings be consistent with equals. This is so because sorted sets (and sorted maps) without explicit comparators behave "strangely" when they are used with elements (or keys) whose natural ordering is inconsistent with equals.