Finally Exception In Java
How to Use Try, Catch & Finally-Exception With Java Program?
Check Also: Verify ArrayList Elements
package com.softwaretestingblog.programs; public class WithTryCatchFinally { public static void main(String[] args) { // TODO Auto-generated method stub try { int i=8; int z=i/0; System.out.println("Executed Sucessfully"+z); } catch(ArithmeticException e) { System.out.println(e.getMessage()); } finally { System.out.println("Finally Block Executed"); } } }
Check Also: Extract Number From String
Output:
/ by zero Finally Block Executed
Leave a Reply