Devaka Cooray wrote:Oh! This was discussed in many times here.
vuthlarhi donald wrote:the question is I don't understand the output
Henry Wong wrote:
But you also need to understand why this is true... The reason why -128 to 127 is a concern with the equality operator, is that autoboxing uses the valueof() method, which in turn uses a "cache" of objects.
Since values within this range is retrieved from a cache, they won't be GC'ed when they are no longer referenced, because the cache still has a reference to them.
Lukas Smith wrote:In K&B 6 book there is Short = 200;
With Short = 5 I think the answer would be different.
Mason Storm wrote:You've created quite a good picture! MSPaint?
Static variable is ONE to THE CLASS not to the instance. Even if you delete (null) all of the references you will have the reference to B1 object. STATIC IS NOT CONNECTED WITH INSTANCE! Am I right?