Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

Java Exception handling using try...catch

class Main {
  public static void main(String[] args) {

    try {

      // code that generate exception
      int divideByZero = 5 / 0;
      System.out.println("Rest of code in try block");
    }
    
    catch (ArithmeticException e) {
      System.out.println("ArithmeticException => " + e.getMessage());
    }
  }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Java #Exception #handling
ADD COMMENT
Topic
Name
4+9 =