Hello Dan,
why is it possible to catch (Exception e) without a try clause?
class Level1Exception extends Exception {}
class Level2Exception extends Level1Exception {}
class Level3Exception extends Level2Exception {}
class Purple {
public static void main(
String args[]) {
char a = 'a';
char b = 'z';
char c = 'A';
char d = 'Z';
char f = 'N';
for (int i = 0; i < 5; i++) {
try { //try clause for catch (Level1Exception e)
try { //try clause for catch (Level2Exception e)
switch (i) {
case 0: throw new Level1Exception();
case 1: throw new Level2Exception();
case 2: throw new Level3Exception();
case 3: break;
default: throw new Exception();
}
a++;
} //End of Level2Exception
//-> now catch Level2Exception
catch (Level2Exception e) {b--;}
finally{c++;}
} //End of
//Level1Exception -> now catch Level1Exception
catch (Level1Exception e) { d--;}
catch (Exception e) {} // WHERE IS TRY- //CLAUSE FOR EXCEPTION?
finally {f++;}
System.out.println ( a+","+c+","+d+","+f+" ");
}
System.out.println("End of loop");
}
}