This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Exceptions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Exceptions" Watch "Exceptions" New topic


Hanna Barenthin

Joined: Mar 13, 2007
Posts: 14
Hi again...

I have a question regarding Runtime-exceptions. Some seem to interrupt the running of the code (for example IllegalMonitorState Exception), i.e. the code beneath the place where the exception is thrown will not run.

However, when using parseInt() which throws a NumberFormatException, the code beneath still runs, like in ex 64:64 in the Master Exam.

How do I know when the program will stop and when it will continue?

BR, Hanna
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
When an exception occurs, the block it is in will terminate. So the code beneath it in the block will not run.
marc weber

Joined: Aug 31, 2004
Posts: 11343

Maybe it would help to post the code you're questioning, so we could walk you through it.

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
Hanna Barenthin

Joined: Mar 13, 2007
Posts: 14
Hi again!

When I was about to post my code I found the answer ;-) parseInt() will not throw an exception unless the string it receives is badly formatted and mine was not! Maybe a bit stupid but I first thought that it was always supposed to be thrown...

I agree. Here's the link:
subject: Exceptions
It's not a secret anymore!