Forums Register Login

a question about exception

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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...
+Pie Number of slices to send: Send
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();
??
You ought to ventilate your mind and let the cobwebs out of it. Use this cup to catch the tiny ads:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 521 times.
Similar Threads
override and overload method
Marcus Green - Qn : 23 - Doubt
Help me friends. I'll appreciate your answer.(Exceptions)
Runtime exception
Which one to throw??
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 18:20:15.