Hacker News new | past | comments | ask | show | jobs | submit login

You can also do a similar thing in Java, as illustrated in this answer on CodeGolf stackexchange: https://codegolf.stackexchange.com/a/28818



Indeed - the integer boxing cache is even required by the language spec!

http://docs.oracle.com/javase/specs/jls/se8/html/jls-5.html#...

(here == means reference not value equality)

"If the value p being boxed is an integer literal of type int between -128 and 127 inclusive (§3.10.1), or the boolean literal true or false (§3.10.3), or a character literal between '\u0000' and '\u007f' inclusive (§3.10.4), then let a and b be the results of any two boxing conversions of p. It is always the case that a == b."




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: