public class AutoBoxingAndUnBoxing
{
public static void main(String[] args)
{
Integer x = 127;
Integer y = 127;
System.out.println(x == y);//true
Integer a = 128;
Integer b = 128;
System.out.println(a == b);//false
System.out.println(a); // prints 128
}
}
How come x==y is true and a==b is false? If it is based on the value(Integer -128 To 127) then 'a' should print -128 right?