/home/wpollock1/public_html/restricted/Java1/ExceptionDemo.java
// To answer HW #3, question 13.18:
class ExceptionDemo {
public static void main ( String [] args ) {
try
{
statement1();
statement2();
statement3();
}
catch ( ArithmeticException ex1 )
{
System.out.println( "Caught Exception 1" );
}
catch ( ArrayIndexOutOfBoundsException ex2 )
{
System.out.println( "Caught Exception 2" );
}
catch ( IllegalArgumentException ex3 )
{
System.out.println( "Caught Exception 3" );
throw ex3;
}
finally
{
System.out.println( "statement4" );
};
System.out.println( "statement5" );
}
static void statement1 () {
System.out.println( "statement1" );
}
static void statement2 () {
System.out.println( "statement2" );
throw new IllegalArgumentException();
}
static void statement3 () {
System.out.println( "statement3" );
}
}