Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

java catch multiple exceptions


catch(IOException | SQLException ex){
     logger.error(ex);
     throw new MyException(ex.getMessage());
}
Comment

Java Multiple catch blocks

class Main {
  public static void main(String[] args) {
    try {
      int array[] = new int[10];
      array[10] = 30 / 0;
    } catch (ArithmeticException e) {
      System.out.println(e.getMessage());
    } catch (ArrayIndexOutOfBoundsException e) {
      System.out.println(e.getMessage());
    } 
  }
}
Comment

Java Multi-catch block

class Main {
  public static void main(String[] args) {
    try {
      int array[] = new int[10];
      array[10] = 30 / 0;
    } catch (ArithmeticException | ArrayIndexOutOfBoundsException e) {
      System.out.println(e.getMessage());
    }
  }
}
Comment

PREVIOUS NEXT
Code Example
Java :: java datatypes 
Java :: display two dimension array java 
Java :: Java loop throug gson JsonElement 
Java :: convert string into time in java 
Java :: java program to find the power of a number 
Java :: java bufferedreader read all lines 
Java :: constraintlayout vs coordinatorlayout 
Java :: set view size android 
Java :: java swing windows 10 look and feel 
Java :: cardview implementation 
Java :: How to get the nth Fibonacci number code in Java using recursion 
Java :: hash table implementation java 
Java :: java if statement 
Java :: how to subtract localdatetime in java 
Java :: socket in java 
Java :: keytool error: java.lang.Exception: Key pair not generated, alias <demo already exists 
Java :: set text from strings.xml 
Java :: what is var in java 
Java :: Calling User-Defined Method in Java 
Java :: java string from byte array 
Java :: java initialize object array 
Java :: tableau de chaîne de caractère en java 
Java :: reversing the linked list 
Java :: java methods 
Java :: android bottom navigation hiding views 
Java :: create hashmap in java 
Java :: lauch java batch 
Java :: check if optional is empty java 
Java :: spring @value default value 
Java :: java method parameters 
ADD CONTENT
Topic
Content
Source link
Name
6+8 =