Lecture18 - A method can throw more than one exception public class Laundry cfw public void doLaundry throws PantsException LingerieException cfw code

Lecture18 - A method can throw more than one exception...

This preview shows page 1 - 9 out of 22 pages.

1 A method can throw more than one exception. public class Laundry { public void doLaundry() throws PantsException, LingerieException { // code that could throw either exception } } public class Foo { public void go() { Laundry laundry = new Laundry (); try { laundry.doLaundry(); } catch(PantsException pex) { // recovery code } catch(LingerieException lex) { // recovery code } }
Image of page 1