First a piece of code, the code is very simple, as follows:
public static void Main (string[] args) { Integer a = Integer.parseint ("3"); Integer B = Integer.parseint ("3"); Integer C = integer.parseint ("184"); Integer d = integer.parseint ("184"); System.out.println (A = = B); System.out.println (c = = d); }
See the code, you think the output should be what it looks like? False, False or true,true, do not know, please self-debug ...
The result of the code output here is: true, False
Why When I saw the result, it was the first reaction (I was a rookie ...). , in the online search for a reason, I have not seen Integer.parseint () of the source (a cursory glance, said did not read).
The approximate reason is that Java will use the common integer (-128-127) as a cache, so when calling parseint ("3"), the corresponding value from the cache, and greater than the 127 cache does not have data, so the above C and D will be two different references, so the range.
(This is my initial understanding, write down later can go deep to see).
There is great God with the source of interpretation, haha ...
Java Integer parseint () (GO)