aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes a question about exception 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 "a question about exception" Watch "a question about exception" New topic
Author

a question about exception

Simo Hayha
Greenhorn

Joined: Jul 02, 2002
Posts: 19
why does the following code can not compile?
public void amethod()throws IOException{
throw new ProtocolException();
}
can can a method throws Excepton? like this:
public void amethod()throws Exception
Barkat Mardhani
Ranch Hand

Joined: Aug 05, 2002
Posts: 787
Hi There:
I guess error is because amethod declaration says
that it can throw one kind of exception while it
actually throws another kind in the method body...
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
What is the error message you get when compiling your class? Something like
unreported exception ProtocolException; must be caught or declared to be thrown
throw new ProtocolException();
??


SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: a question about exception