Answers for "catch and try 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
-1

Java try catch Syntax

try {
  //  Block of code to try
}
catch(Exception e) {
  //  Block of code to handle errors
}
Posted by: Guest on October-03-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language