
what is advantage to catch smaller exception first and then normal exception. I mean we normally catch SQLException first and then Exception.

Hi,
The exceptions should be from the specific to generic this is the rule to be followed.

Thanks for the reply. Is there any advantage apart from the rule that needs to be followed?

class MyException{ public static void main(String ar[]) { int x=0; try { System.out.println(100/x); } catch(Exception e) { } catch(ArithmeticException ae) { System.out.println("u r inside arithmetic exception"); } } } In general,Exception is the super class of all exceptions,so,we hv to give general exception first then smaller exceptions(in case,if u mention normal and smaller exceptions).....or we can directly mention smaller exceptions with out giving normal exception....or we can directly give normal exception only(without giving smaller exceptions),which can handles all exceptions under it.
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.