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

throw Exception question

 
Yan Bai
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Got compile error at line1:
Unreported Exception
Compare to this code:

compile ok.
Why?
 
Alfred Kemety
Ranch Hand
Posts: 279
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Compiler check only on Checked Exceptions and not non-checked exceptions Exception exception is a checked exception. All run-time exceptions - RuntimeException and all its subclasses - are non-checked exceptions, so the compiler doesn't check on them during compilation.
HTH
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic