Skip to content

Instantly share code, notes, and snippets.

View bergmanngabor's full-sized avatar

Gábor Bergmann bergmanngabor

  • Budapest, Hungary
View GitHub Profile
@bergmanngabor
bergmanngabor / IntLongWat.java
Created May 19, 2012 18:49
Playing with semantic holes in Java's notions of equality
public class IntLongWat {
public static void main(String[] args) {
System.out.println(new Integer(1).equals(1)); // true
System.out.println(new Long(1).equals(1)); // false, it only equals 1L - so much for semantic equivalence
System.out.println(new Integer(1).equals(new Long(1))); // false... Y U NO EQUAL?
// although
System.out.println(new Integer(1) == 1); // true