package edu.bloomu.ch5a;

import java.math.BigInteger;

/**
 * Demonstrates the difference between primitive type variables and reference variables,
 * and the difference between shallow equality and deep equality.
 * 
 * @author Drue Coles
 */
public class EqualsDemo {

    public static void main(String[] args) {
        int v1 = 12_345_678;
        int v2 = 12_345_678;
        if (v1 == v2) {
            System.out.printf("%,d = %,d (TRUE) %n", v1, v2);
        } else {
            System.out.printf("%,d = %,d (FALSE) %n", v1, v2);
        }
        
        BigInteger b1 = new BigInteger("12345678");
        BigInteger b2 = new BigInteger("12345678");
        
        // shallow equality
        if (b1 == b2) { 
            System.out.printf("%,d = %,d (TRUE) %n", b1, b2);
        } else {
            System.out.printf("%,d = %,d (FALSE) %n", b1, b2);
        }
        
        // deep equality 
        if (b1.equals(b2)) { 
            System.out.printf("%,d = %,d (TRUE) %n", b1, b2);
        } else {
            System.out.printf("%,d = %,d (FALSE) %n", b1, b2);
        }
    }
}