Write a program in java to demonstrate exception with finally block?

class ExceptionFinally

{

      public static void main(String arg[])

      {

            try

            {

                  int a=Integer.parseInt(arg[0]);

                  int b=Integer.parseInt(arg[1]);

                  System.out.println(a/b);

            }

            catch(Exception e)

            {

                  System.out.println(e);

            }

            finally

            {

                  System.out.println("Hello Finally");

            }

            System.out.println("Normal Flow");

      }

}

Exception Handling Finally Block.PNG

, , , , , , ,

Leave a Reply