/*
 * Created on Jul 6, 2005
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */

/**
 * @author sslee
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */

import java.text.DecimalFormat;

public class ReferenceTest {

	//------------------------------------------------------------------
	// This demonstrates some of the different things that can happen
	// when you deal with objects and references. 
	//------------------------------------------------------------------
	public static void main(String[] args) {
		
		DecimalFormat formatter1 = new DecimalFormat("0.##");
		DecimalFormat formatter2 = new DecimalFormat("0.###");
		final double VALUE = 0.1234567;
		
		// Showing how each formatter object behaves at this point.
		System.out.println("      Status Check 1");
		System.out.println("The actual VALUE: " + VALUE);
		System.out.println("formatter1 gives: " + formatter1.format(VALUE));
		System.out.println("formatter2 gives: " + formatter2.format(VALUE));
		System.out.println("---------------------------------------------");
		
		DecimalFormat formatter3;
		
		//-------------------------------------------------
		// At this point "formatter3" is equal to 'null'
		//-------------------------------------------------
		
		formatter3 = formatter2;
		
		// Showing how each formatter object behaves at this point.
		System.out.println("      Status Check 2");
		System.out.println("The actual VALUE: " + VALUE);
		System.out.println("formatter1 gives: " + formatter1.format(VALUE));
		System.out.println("formatter2 gives: " + formatter2.format(VALUE));
		System.out.println("formatter3 gives: " + formatter3.format(VALUE));
		System.out.println("---------------------------------------------");
		
		formatter3.applyPattern("0.######");
		
		// Showing how each formatter object behaves at this point.
		System.out.println("      Status Check 3");
		System.out.println("The actual VALUE: " + VALUE);
		System.out.println("formatter1 gives: " + formatter1.format(VALUE));
		System.out.println("formatter2 gives: " + formatter2.format(VALUE));
		System.out.println("formatter3 gives: " + formatter3.format(VALUE));
		System.out.println("---------------------------------------------");
		
		formatter2 = new DecimalFormat("0.#");
		
		// Showing how each formatter object behaves at this point.
		System.out.println("      Status Check 4");
		System.out.println("The actual VALUE: " + VALUE);
		System.out.println("formatter1 gives: " + formatter1.format(VALUE));
		System.out.println("formatter2 gives: " + formatter2.format(VALUE));
		System.out.println("formatter3 gives: " + formatter3.format(VALUE));
		System.out.println("---------------------------------------------");
		
		formatter3.applyPattern("0.####");
		
		// Showing how each formatter object behaves at this point.
		System.out.println("      Status Check 5");
		System.out.println("The actual VALUE: " + VALUE);
		System.out.println("formatter1 gives: " + formatter1.format(VALUE));
		System.out.println("formatter2 gives: " + formatter2.format(VALUE));
		System.out.println("formatter3 gives: " + formatter3.format(VALUE));
		System.out.println("---------------------------------------------");
	}
}
