java try catch
try{ //Code that is checked for error } catch(Exception e){ //Code runs when error is caught }
Java Exceptions - Try...Catch
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."); } } }