Possible Duplicate:
Integer wrapper objects share the same instances only within the value 127?
Why is == true for some Integer objects?
class One
{
public static void main(String[] args)
{
Integer i1 = 10;
Integer i2 = 10;
if (i1 == i2)
{
System.out.println("In if ");
}
else
{
System.out.println("in else");
}
}
}
The output of the above program is In if
but if the values of i1 and i2 are changed to 1000 then output is In else.
I know that autoboxing is taking place here but unable to understand the reasons of the output. Thank You!