Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

throws multiple exception

import java.io.*;
class Main {
  public static void findFile() throws NullPointerException, IOException, InvalidClassException {
    
    // code that may produce NullPointerException
    … … … 

    // code that may produce IOException
    … … … 

    // code that may produce InvalidClassException 
    … … … 
  }

  public static void main(String[] args) {
    try{
      findFile();
    } catch(IOException e1){
      System.out.println(e1.getMessage());
    } catch(InvalidClassException e2){
      System.out.println(e2.getMessage());
    }
  }
}
Source by www.programiz.com #
 
PREVIOUS NEXT
Tagged: #throws #multiple #exception
ADD COMMENT
Topic
Name
2+3 =