This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes problrm with throw ing a exception but catching into a method declaring thorws Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "problrm with throw ing a exception but catching into a method declaring thorws" Watch "problrm with throw ing a exception but catching into a method declaring thorws" New topic
Author

problrm with throw ing a exception but catching into a method declaring thorws

thirumala raju
Greenhorn

Joined: Jan 03, 2008
Posts: 9
hi folks,

void met()throws IOException
{
System.out.println("RRRRW");
throw IOException;
}

the above piece of code i have declared a method to throws the exception which is occuring in this method IOException.. bbut it is having compile error

raja
abhishek pendkay
Ranch Hand

Joined: Jan 01, 2007
Posts: 184
your throw statement is not correct... when you use throw you actually throw a object of IOException (or any other exception you want to throw)...
the correct code would be

[ January 04, 2008: Message edited by: abhishek pendkay ]

The significant problems we face cannot be solved by the same level of thinking which created them – Einstein
SCJP 1.5, SCWCD, SCBCD in the making
 
GeeCON Prague 2014
 
subject: problrm with throw ing a exception but catching into a method declaring thorws