Created
April 1, 2014 21:26
-
-
Save djeikyb/9923543 to your computer and use it in GitHub Desktop.
This file contains 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 characters
public class ObjectsAndEquals | |
{ | |
public static void main(String[] args) | |
{ | |
Integer m0 = 127; | |
Integer m1 = 127; | |
System.out.println(m0 == m1); // true | |
System.out.println(m0.equals(m1)); // true | |
Integer n0 = 128; | |
Integer n1 = 128; | |
System.out.println(n0 == n1); // false | |
System.out.println(n0.equals(n1)); // true | |
System.out.println(n0 == 128); // true | |
System.out.println(128 == n0); // true | |
System.out.println(n0.equals(128)); // true | |
System.out.println((m0+1) == n1); // true | |
System.out.println((Integer)(m0+1) == n1); // false | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Line 12 is boggling.