I have a simple java class
public class T {
public static void main(String[] args) {
Integer x = 0;
Integer y = 0;
Integer a = 255;
Integer b = 255;
System.out.println( (x==y) );
System.out.println( (a==b) );
}
The console output result is:
true
false
Why is the output for comparing x with y are different from comparing a with b? Why does Java doesn't create objects for small int values?