File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes supersubcatch Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "supersubcatch" Watch "supersubcatch" New topic
Author

supersubcatch

usha prithvi
Ranch Hand

Joined: Jun 22, 2005
Posts: 31
hi,
In the following code,i am unable to understand the error. can someone expalin me the error.

public class SuperSubCatch {

public static void main(String[] args) {
try{
int a = 0;
int b = 43/a;

}catch(ArithmeticException e){
System.out.println(" generic exception catch ");
}catch (ArithmeticException e){
System.out.println(" this is never reached");
}
}
}

thanks
usha
shetal bansal
Ranch Hand

Joined: May 09, 2005
Posts: 63
You are catching the same exception twice.If you remove the second catch statement or chanage it to catch(Exception e), the code will work.
usha prithvi
Ranch Hand

Joined: Jun 22, 2005
Posts: 31
thankz for ur response
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: supersubcatch
 
Similar Threads
about finally and return statement
A runtime exception is throws in the catch clause:
return statement effect in Exception class
ArithmeticException in doubles
2 objects EXCEPTION