B
bruce00
Gast
Moin liebe Community,
habe folgendes vor und brauche eure Hilfe:
Ich muss eine Exxception programmieren(Exception1 ), die eine andere Exception(Exception2) auslöst. Ich habe bei Java Doc nachgeguckt und im Internet auch.
Hier mein Code:
PS: bin so confused #.#
habe folgendes vor und brauche eure Hilfe:
Ich muss eine Exxception programmieren(Exception1 ), die eine andere Exception(Exception2) auslöst. Ich habe bei Java Doc nachgeguckt und im Internet auch.
Hier mein Code:
Java:
//Klasse A
public void Method1(int a) throws Exception1{
try{
if (bedingung1) {
//Anweisung
} else {
throw new Exception1("Exception1 wird geworfen!!");
}
}
catch(Exception1 e){
}
}
//hier muss ich Exception1 abfangen mit try catch Block, die soll Exception2 auslösen
Java:
//Klasse B
public void Method1() throws Exception2, Exception1{
if () {
klasseA.Method1();
} else {
throw new Exception2("Exception2");
}
}
// hier darf ich nicht abfangen, keine try catch Blöcke und soll abgeworfen werden!
PS: bin so confused #.#
Zuletzt bearbeitet von einem Moderator: