• Post Reply Bookmark Topic Watch Topic
  • New Topic

unable to use throws clause inside run()  RSS feed

 
siva sambo
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends, In the code below i want to remove the exception handling code (ie try-catch) and use throws clause. How do i do it??


thanks in advance
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't. If the superclass that you inherit the method from does not have the checked exception IOException or one of its superclasses in its throws clause, then you can't list the checked exception in the throws clause of the method when you override it.
[ February 24, 2006: Message edited by: Keith Lynn ]
 
Jeff Albertson
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are overriding a method (run) that throws no checked exceptions, so you can't throw IOException.

You need to think about how you want your code to behave. In high-level terms, what do you want to happen if an IOException occurs?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!