How do I compare two Integers? [duplicate]
This is what the equals method does: public boolean equals(Object obj) { if (obj instanceof Integer) { return value == ((Integer)obj).intValue(); } return false; } As you can see, there’s no hash code calculation, but there are a few other operations taking place there. Although x.intValue() == y.intValue() might be slightly faster, you’re getting into … Read more