Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Exception Handling  RSS feed

 
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
Saloon Keeper
Posts: 6979
110
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!