This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
thirumala raju
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 184
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic