Salve a tutti non riesco a capire perchè la terza chiamata genera un excep di tipo exception2.
Codice PHP:
class Exception1 extends Exception {}
class Exception2 extends Exception {}
public class Test {
static int method(String x) throws Exception1, Exception2 {
try {
if (x.equals("aabbcc")) {
return 0;
}
if (x.length() < 9) {
return method("a" + x + "c");
}
throw new Exception2();
}
catch(Exception1 e) {
throw new Exception2();
}
catch(Exception2 e) {
throw new Exception1();
}
}
public static void main(String[] args) throws Exception1, Exception2 {
System.out.println(Test.method("a"));
System.out.println(Test.method("bb"));
System.out.println(Test.method("ccc"));
}
}