This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan 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 Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Exceptions" Watch "Exceptions" New topic
Author

Exceptions

Hanna Barenthin
Greenhorn

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
Sheriff

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
sscce.org
Hanna Barenthin
Greenhorn

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...

Thanks!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Exceptions
 
Similar Threads
should user defined exception be a checked or unchecked exception?
Exceptions, implementing
Correct exception handling
url-pattern
Shift with -ve operand???