ee - System.out.println( "ERROR...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
public class ExceptionExample { public static void main(String[] args) { foo(); try { bar(); } catch (IndexOutOfBoundsException iobe) { System.out.println( "ERROR 1" ); } catch (ArithmeticException ae) { System.out.println( "ERROR 2" ); } finally { System.out.println( "DONE" ); } } public static void foo() { // PROGRAM LINE A try { // PROGRAM LINE B } catch (NullPointerException npe) { System.out.println(npe.getMessage()); npe.printStackTrace(); } } public static void bar() { // PROGRAM LINE C try { // PROGRAM LINE D methodX(); } catch (NullPointerException npe) {
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: System.out.println( "ERROR 3" ); } catch (IndexOutOfBoundsException iobe) { System.out.println( "ERROR 4" ); } System.out.println( "DONE BAR" ); } public static void methodX() { // PROGRAM LINE E try { // PROGRAM LINE F } catch (IndexOutOfBoundsException iobe) { System.out.println(iobe.getMessage()); iobe.printStackTrace(); } catch (NumberFormatException nfe) { System.out.println( "ERROR 5" ); return ; } finally { System.out.println( "DONE METHODX" ); } } }...
View Full Document

This note was uploaded on 08/08/2008 for the course CS 302 taught by Professor Willbenton during the Spring '07 term at Wisconsin.

Ask a homework question - tutors are online