Hallo,
ich beschäftige mich gerade mit dem Werfen von Exceptions. So ganz klappt es aber noch nicht.
Folgender Fehler wird ausgegeben:
constructor MySimpleException in class MySimpleException cannot be applied to given types
Code:
ich beschäftige mich gerade mit dem Werfen von Exceptions. So ganz klappt es aber noch nicht.
Folgender Fehler wird ausgegeben:
constructor MySimpleException in class MySimpleException cannot be applied to given types
Code:
Code:
package Exceptions;
public class MainClass2 {
public static void main(String[] args) {
MainClass2 koko = new MainClass2();
try {
koko.methodeOne();
} catch (MySimpleException ex) {
ex.getMessage();
}
}
public void methodeOne() throws MySimpleException {
int i = -5;
methodeTwo(i);
}
public void methodeTwo(int i) throws MySimpleException {
if (i < 0) {
throw new MySimpleException("Zahl kleiner als Null");
}
}
}
Code:
package Exceptions;
public class MySimpleException extends Exception {
}