// File: Equality.java
// Copyright (C) 2010 Gregory D. Weber
// Demonstrates the differences between == and equals.

public class Equality 
{
    public static void main (String [] args)
    {
        Object o = new Object();
        Object p = new Object();
        Object q = o;
        Integer i = new Integer(21);
        Integer j = new Integer(21);
        Integer k = i;

        System.out.println("o == p: " + (o == p));
        System.out.println("o equals p: " + (o.equals(p))); 
        System.out.println("o == q: " + (o == q));
        System.out.println("o equals q: " + (o.equals(q))); 
 
        System.out.println("i == j: " + (i == j)); 
        System.out.println("i equals j: " + (i.equals(j))); 
        System.out.println("i == k: " + (i == k)); 
        System.out.println("i equals k: " + (i.equals(k))); 
    }
}

 
