Results 1 to 3 of 3
  1. #1
    Join Date
    May 2013
    Posts
    2
    Rep Power
    0

    Default Finally Block in Exception

    What is the purpose of using Finally Block?
    I write code without Finally Block and with Finally Block. The result is same.

    CODE with FinallyBlock:

    public class Exception{
    public static void main(String[] args){
    int x = 4, y = 0;
    try{
    System.out.println(x/y);
    } catch(ArithmeticException e){
    System.out.println(e.toString());
    }
    finally{
    System.out.println("CODE with FinallyBlock");
    }
    }
    }

    CODE without FinallyBlock:

    public class Exception{
    public static void main(String[] args){
    int x = 4, y = 0;
    try{
    System.out.println(x/y);
    } catch(ArithmeticException e){
    System.out.println(e.toString());
    }

    System.out.println("CODE without FinallyBlock");

    }
    }

    I'm waiting for your helps, friends. Thanks

  2. #2
    jim829 is online now Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,785
    Rep Power
    5

    Default Re: Finally Block in Exception

    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  3. #3
    Join Date
    May 2013
    Posts
    2
    Rep Power
    0

Similar Threads

  1. Replies: 2
    Last Post: 08-30-2012, 04:51 PM
  2. Replies: 2
    Last Post: 10-08-2010, 12:08 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •