Answers for "why try catch block is used in java"

7

try catch java

public class MyClass {
  public static void main(String[ ] args) {
    try {
      int[] myNumbers = {1, 2, 3, 4, 5, 6};
      System.out.println(myNumbers[10]);
    } catch (Exception e) {
      System.out.println("Something went wrong. check again");
    }
  }
}
Posted by: Guest on July-17-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language