Search
 
SCRIPT & CODE EXAMPLE
 

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)
Comment

where finally block will not be executed

Finally block will not be executed whenever jvm shutdowns. 
If we use system.exit(0) in try statement finally block if present 
will not be executed.
Comment

PREVIOUS NEXT
Code Example
Java :: random in java a to b 
Java :: list files in directory java 
Java :: how to get child from layout in android 
Java :: get raondom from array java 
Java :: java parseint 
Java :: copy constructor in java 
Java :: java nested loop 
Java :: how to add element to end of array java 
Java :: java count to 10 
Java :: set path in windows 
Java :: java first letter to upper case 
Java :: Java Creating a Vector 
Java :: java unit test an api 
Java :: java mongodb find with multiple conditions 
Java :: spring maven plugin 
Java :: spigot dispatchcommand 
Java :: addall java 
Java :: compile java 
Java :: string format java 
Java :: java string length validation regex 
Java :: java print type of variable 
Java :: printing multiple variables in java 
Java :: How to efficiently find the longest common subsequence of two strings, in Java? 
Java :: spring boot MVC config 
Java :: How to efficiently find the area of largest rectangle that can be formed by adjacent buildings with known heights, in Java? 
Java :: BufferredReader Class 
Java :: how to add string to array in java 
Java :: java bufferedreader read all lines 
Java :: java first character string number 
Java :: hash table implementation java 
ADD CONTENT
Topic
Content
Source link
Name
4+8 =