Skip to content

Instantly share code, notes, and snippets.

@lawesson
Created September 30, 2016 16:57
Show Gist options
  • Save lawesson/3e060879acb67f792ba309c3b12927ae to your computer and use it in GitHub Desktop.
Save lawesson/3e060879acb67f792ba309c3b12927ae to your computer and use it in GitHub Desktop.
Testing the java.lang.Integer.IntegerCache
public class IntegerCacheTest {
private static void test(Integer i, Integer i2) {
System.out.println(i);
if (i == i2) System.out.println(" the same");
if (i != i2) System.out.println(" different");
if (i.equals(i2)) System.out.println(" equal");
}
public static void main(String[] args) {
test(17, 17);
test(200, 200);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment