This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

why won't my catch catch?

 
Momo Sawada
Greenhorn
Posts: 24
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi again... and thank you to everyone who took the time to give advice to my very trivial questions...(sorry!)
i have a code... which looks something like this...



but i don't understand why my NumberFormatException catch block won't work... the ArithmeticException catch block works just fine..
Thank you very much!!!
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's never called because inside the try { ... } block there is nothing that will ever throw a NumberFormatException.

Line 6 might throw a NumberFormatException, but it's outside the try { ... } block.

By the way, all those System.exit(0); calls are not necessary.
 
Momo Sawada
Greenhorn
Posts: 24
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ohhhh... i get your meaning...
Thanks you!!!
oh, and i just wanted to put the system exits because i want the program to exit without me pressing the stop activate tool...
 
Campbell Ritchie
Sheriff
Pie
Posts: 47278
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't need to stop the program; it will exit when it reaches the end of the main method.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic