Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exceptions

 
Hanna Barenthin
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe it would help to post the code you're questioning, so we could walk you through it.
 
Hanna Barenthin
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic