Integer constant pool
Posted by zone817Java uses a caching mechanism for Integer , similar to the String Pool . It caches the Integer values from -128 to 127 , meaning '==' comparisons for values in this range returns true .
Integer a=127; Integer b=127; System.out.println(a==b);//prints true a=128; b=128; System.out.println(a==b);//prints false
0 comments:
Post a Comment