Execute code after a try…catch block, irrespective of the outcome.
try{
int[] myNumbers ={1,2,3};
System.out.println(myNumbers[10]);
}catch(Exception e){
System.out.println("Something went wrong.");
}finally{
System.out.println("The 'try catch' is finished.");
}
Definition and Usage
The “finally” keyword is employed to execute code (in conjunction with exceptions handled by try…catch statements) regardless of whether an exception occurs or not.