Topic
  • 1 reply
  • Latest Post - ‏2007-11-16T11:34:26Z by SystemAdmin
SystemAdmin
SystemAdmin
1240 Posts

Pinned topic What is the basic difference between the 2 approaches to exception handling

‏2007-11-16T06:24:21Z |
What is the basic difference between the 2 approaches to exception handling.
1> try catch block and
2> specifying the candidate exceptions in the throws clause?
When should you use which approach?
Updated on 2007-11-16T11:34:26Z at 2007-11-16T11:34:26Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    1240 Posts

    Re: What is the basic difference between the 2 approaches to exception hand

    ‏2007-11-16T11:34:26Z  
    Well, the basic difference is who is going to handle the exception, the caller or you?
    If you declare that your method is throwing exception then you are passing the
    responsibility of handling that exception to the caller, and he will decide how to handle it.
    If you decide to catch an exception using try & catch , then you are handling the exception
    on the spot and the exception would not propagate further in the calling stack.