Hey ich schreibe einen Code und soll nun eine zweite Methode einbauen. Wenn ich:
public int TwentyBy(){
//...
}
bekomme ich die Fehlermeldung
illegal start of expression
wenn ich aber
int TwentyBy;{
//...
}
funktioniert es, nun aber die Frage ob das eine Methode ist?
Hier ist der gesamte Code
public class excep {
public static void main(String[] args) throws Exception {
float zahl;
try {
zahl = Integer.parseInt(args[0]);
if (zahl > 10) {
throw new Exception("Zahl darf nicht größer als 10 sein!");
}
}catch (ArrayIndexOutOfBoundsException e) {
System.out.println("Bitte gib ein Argument!");
zahl = 2;
e.printStackTrace();
} catch (NumberFormatException f) {
System.out.println("bitte gib eine Zahl ein!");
zahl = 3;
f.printStackTrace();
}
System.out.println("Deine Zahl: " + zahl);
int TwentyBy;{
System.out.println("Der Quotient mit 20: "+ 20/zahl);
}
}