Integer constant pool

0

Java 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

Read more »

0 comments:

Post a Comment

© Zone817. Powered by Blogger.