/** * @author monika heiner * @version 1.01 * @date 14.05.2012 * @class ProgramPattern */ import java.util.Scanner; public class ProgramPattern1 { public static void main(String[] argv) { // throws MyExceptionType1, MyExceptionType2 { try { // standard functionality if (true) { // ''true' stands for some condition throw new MyExceptionType1 (); // anonymous new object } else { MyExceptionType2 objectName = new MyExceptionType2(); // named new object throw objectName; } // if } // try catch (MyExceptionType1 e) { // my exception handling1 } // catch catch (MyExceptionType2 e) { // my exception handling2 } // catch catch (Exception e) { // standard exception handling } // catch finally { // you never know } // finally } // main } // ProgramPattern1 //------------------------ cut here into separate files -------------------------------- // definition of new types/classes // by referencing to a similar already existing type/class class MyExceptionType1 extends Exception { public MyExceptionType1 () { // constructor1 } public MyExceptionType1 (String s) { // constructor2 } } // MyExceptionType1 //------------------------ cut here into separate files -------------------------------- class MyExceptionType2 extends Exception { public MyExceptionType2 () { } } // MyExceptionType2