If you want to compare objects in Java use .equals()
.
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.equals(y)) );
System.out.println( (a.equals(b)) );
}
Using ==
you will just compare the references to both objects, which wont be the same.
Use ==
only when comparing primitive values.