/* TestException6.java CIS 260 Dave Klick 2016-02-03 This program shows how you can throw an exception and handle it. */ public class TestException6 { public static void main(String[] args) { for (int i=0; i<10; i++) { try { generateException(i); System.out.println("Passed: " + i); } catch (MyException e) { System.out.println("Exception thrown: " + i); } } } private static void generateException(final int n) throws MyException { if (n % 2 != 0) throw new MyException(); } } class MyException extends Exception { }