class X { void test(int x, int y) { if (Integer.valueOf(x).equals(y)) { System.out.println(x == y); } if (!Integer.valueOf(x).equals(y)) { System.out.println(x == y); } Integer xx = Integer.valueOf(x); if (xx.equals(y)) { System.out.println(x == y); } if (x == y) { System.out.println(xx.equals(y)); } if (x != y) { System.out.println(xx.equals(y)); } } void testDouble(double x, double y) { if(Double.valueOf(x).equals(y)) { // Can be false if x and y are NaNs System.out.println(x == y); } if(!Double.valueOf(x).equals(y)) { // Can be true if x and y are 0.0 and -0.0 System.out.println(x == y); } if (x == y && Double.valueOf(x).equals(y)) {} } void test2(byte x, byte y) { if(x != y && Byte.valueOf(x) == Byte.valueOf(y)) { System.out.println("Impossible"); } } void boxUnbox(int x) { if(Integer.valueOf(x) > 5 && Integer.valueOf(x) < 0) {} } }