Answers for "try catch statement in java"

3

What is a try block in java?

Java try block is used to enclose the code that might throw an exception
Posted by: Guest on June-18-2021
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