Last active
November 23, 2015 14:30
-
-
Save up1/1b8b815ea6b3711e34b8 to your computer and use it in GitHub Desktop.
Java :: Pzzle
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
import static java.lang.System.out; | |
public class Aha { | |
public static void main(String ... args) { | |
Integer a = 1000, b = 1000; | |
out.println(a == b); | |
Integer c = 100, d = 100; | |
out.println(c == d); | |
} | |
} |
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 static Integer valueOf(int i) { | |
assert IntegerCache.high >= 127; | |
if (i >= IntegerCache.low && i <= IntegerCache.high) | |
return IntegerCache.cache[i + (-IntegerCache.low)]; | |
return new Integer(i); | |
} |
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
private static class IntegerCache { | |
static final int low = -128; | |
static final int high; | |
static final Integer cache[]; | |
static { | |
// high value may be configured by property | |
int h = 127; | |
... | |
} | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment