same objects //how is this possible please explain
how if(i3==i4) and if(i1!=i2) both can be true
Post by:marc weber
This is due to autoboxing. In your first example, the value being boxed is outside the range -128 to 127. In your second example, the value is within that range. As explained under JLS - 5.1.7 Boxing Conversion...
If the value p being boxed is true, false, a byte, a char in the range \u0000 to \u007f, or an int or short number between -128 and 127, then let r1 and r2 be the results of any two boxing conversions of p. It is always the case that r1 == r2.
Post by:Shashank Agarwalg
, Ranch Hand
Thanks for the solution.
Post by:Jesper de Jong
Please note that this exact same question has been asked and answered here many times before: