• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exception Handling

 
Ramesh Pramuditha Rathnayake
Ranch Hand
Posts: 178
2
Java MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Why line 9 gives compile error while line 5 is being compiled..?
(This error occurs in JDK 1.7 only!)
 
Stephan van Hulst
Bartender
Pie
Posts: 5590
55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The compiler reasons that the only type of Exception that you can catch in your catch-block is a runtime exception, which you may always rethrow without having to declare it.

Change the empty comment line to throw a non-runtime exception and you will see that the compiler will complain the same way for line 5.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic