Equality and Java boxed types

Can somebody please explain the reasoning behind Java’s semantics for equals when applied to Integer and Long?

Seriously, why does Integer.valueOf(1).equals(Long.valueOf(1)) return false?

When is this a useful semantics?

Trackbacks & Pingbacks 1

  1. From Miscellaneous-B » Java Posse on the case… on 26 Feb 2006 at 11:51 pm

    [...] Approximately 40min into podcast #034 the Java Posse address my question about equals() between Java Long and Int objects. [...]

Post a Comment

You must be logged in to post a comment.