Revisions
-
ujhelyiz revised this gist
May 22, 2012 . 1 changed file with 16 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,18 +2,27 @@ 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 System.out.println(new Long(1) == 1); // true... WAT? they are == but not equals() ? // so then, transitively... // System.out.println(new Integer(1) == new Long(1)); // COMPILE ERROR... CLEVER BASTARD Object oInt = new Integer(1); Object oLong = new Long(1); System.out.println(oInt == oLong); // false, of course - so much for transitivity } } -
bergmanngabor revised this gist
May 19, 2012 . 1 changed file with 14 additions and 14 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,19 +1,19 @@ 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 System.out.println(new Long(1) == 1); // true... WAT? they are == but not equals() ? // so then, transitively... // System.out.println(new Integer(1) == new Long(1)); // COMPILE ERROR... CLEVER BASTARD Object oInt = new Integer(1); Object oLong = new Long(1); System.out.println(oInt == oLong); // false, of course - so much for transitivity } } -
bergmanngabor created this gist
May 19, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ 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 System.out.println(new Long(1) == 1); // true... WAT? they are == but not equals() ? // so then, transitively... // System.out.println(new Integer(1) == new Long(1)); // COMPILE ERROR... CLEVER BASTARD Object oInt = new Integer(1); Object oLong = new Long(1); System.out.println(oInt == oLong); // false, of course - so much for transitivity } }