/**
    Demo of exception handling. 
    Comment out the line: int i = Integer.parseInt("a");
    to see the NullPointerException handler at work. 

    @author A. T. Ozgelen
 */ 
public class TryCatchDemo {
    public static void main(String[] args){
	Coin c = null;     
	try {
	    int i = Integer.parseInt("a");
	    c.flip();
	}
	catch(NumberFormatException nfe) {
	    System.out.println("there was an error: " + nfe.getMessage());
	    nfe.printStackTrace();
	}
	catch(NullPointerException npe) {
	    System.out.println("You should probably initialize the Coin " + 
			       "object rather than catching this exception!");
	}
	finally {
	    System.out.println("Done!");
	}
    }
}
