Skip to content

Instantly share code, notes, and snippets.

@massahud
Created March 18, 2013 18:12
Show Gist options
  • Save massahud/5189412 to your computer and use it in GitHub Desktop.
Save massahud/5189412 to your computer and use it in GitHub Desktop.
Java autoboxing cache
public class AutoboxTest {
public static void main(String[] args) {
Integer i1 = 127;
Integer i2 = 127;
System.out.println(i1 + " == " + i2 + "? " + (i1==i2));
i1 = 128;
i2 = 128;
System.out.println(i1 + " == " + i2 + "? " + (i1==i2));
i1 = -128;
i2 = -128;
System.out.println(i1 + " == " + i2 + "? " + (i1==i2));
i1 = -129;
i2 = -129;
System.out.println(i1 + " == " + i2 + "? " + (i1==i2));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment