Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

exception (source: K&B)

 
adam Lui
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
from K&B


how can we possibly solve this error?
I tried different approach and not quite understood how...
 
Kelvin Chenhao Lim
Ranch Hand
Posts: 513
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Adam,

Animal.eat() declares a checked exception, so any client code must either catch the exception or declare the checked exception as well. Thus you have two options for fixing the compilation error:

Handling the checked exception:

Declaring the checked exception:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic