Exception Handling in Java


Use exception handling to manage runtime errors in your code.

Source Code

try {
    int[] myNumbers = {1, 2, 3};
    System.out.println(myNumbers[10]); // error!
} catch (Exception e) {
    System.out.println("Something went wrong.");
} finally {
    System.out.println("The 'try catch' is finished.");
}
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments