// Demonstrates the difference between comparing primitive data and objects public class Objects { public static void main (String[] args) { int x, y; Integer a, b; x = 5; y = 5; System.out.println("x = " + x + ", y = " + y + ", x == y is " + (x == y)); a = 5; b = 5; System.out.println("a = " + a + ", b = " + b + ", a == b is " + (a == b)); a = new Integer(5); b = new Integer(5); System.out.println("a = " + a + ", b = " + b + ", a == b is " + (a == b)); System.out.println("a = " + a + ", b = " + b + ", a == b is " + a.equals(b)); } }