aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Eeceptions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Eeceptions" Watch "Eeceptions" New topic
Author

Eeceptions

amrit singh
Ranch Hand

Joined: Nov 03, 2000
Posts: 42
Hi all !!!
when catching multiple exception the class hierarchy of exception is imortant i mean more specific must come b4
is this also true when we declare in throws statement
steve richardson
Greenhorn

Joined: Dec 16, 2000
Posts: 3
No, when a method is declared to throw a number of Exceptions, there is no requirement to list these in any particular order of precedence. Generally though, you should try and throw as specifically as you can to help the client programmer and make the code cleaner and easier to read. On the other hand, though, if you have a method that throws five different exceptions that are all, say, sub-classes of IOException, it is better to simply say throws IOException, and then to catch the specific sub-classes in the calling code. Hope this is of some use.
Regards,
Steve
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Eeceptions
 
Similar Threads
Interface
Transaction RolledBackLocal Exception
Exception confusion
NullPointerException for the Date field in ResultSet
CORBA - OBJECT_NOT_EXIST exception