wood burning stoves 2.0*
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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
 
jQuery in Action, 2nd edition
 
subject: problrm with throw ing a exception but catching into a method declaring thorws
 
Similar Threads
a question about catch exception
Overiding with Exceptions
Exceptions
a question about exception
difference between throw and throws