Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

does finally block executed after crash

///Finally block will be executed even if the catch failes to "catch" the exception.
    public static void main(String[] args) {
        try{
            throw new ArrayIndexOutOfBoundsException();
        }catch(NullPointerException e){
            System.out.println("CATCH BLOCK");
        }finally{
            System.out.println("FINALLY");
        }
    }
    
//output: FINALLY
//Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException
       // at test.main(test.java:4)
 
PREVIOUS NEXT
Tagged: #finally #block #executed #crash
ADD COMMENT
Topic
Name
9+1 =