Java versuche fangen
try{
//Code that is checked for error
} catch(Exception e){
//Code runs when error is caught
}
Christina Zhang
try{
//Code that is checked for error
} catch(Exception e){
//Code runs when error is caught
}
public class Main {
public static void main(String[ ] args) {
try {
int[] myNumbers = {1, 2, 3};
System.out.println(myNumbers[10]);
} catch (Exception e) {
System.out.println("Something went wrong.");
}
}
}