• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Try/catch allowing exception through

 
Ranch Hand
Posts: 63
IntelliJ IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have another topic about the full code this part is from but it started out with a different question and branched out. Thought it might not be accurate to keep posting there when I'm asking different questions.

I'm trying to catch the NumberFormatException and write my own message and allow the program to continue after it.


Output:
Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: For input string: "2.45"
 
Sheriff
Posts: 28344
97
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I just answered that question in your other thread.
 
Suane Mane
Ranch Hand
Posts: 63
IntelliJ IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Seen. Wanted to update this topic with another try/catch problem of the same program.



The aim of this method is to show the number of occurrences of user entered number. If the text field is empty, it's supposed to show the number of values currently in the list (only testing on console for now. Once it is fully functional I will try to add the message in the window so it's visible to the user).
I'm pretty sure the code that is raising the exception is within the try block, yet the exception still goes through.
 
Paul Clapham
Sheriff
Posts: 28344
97
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Suane Mane wrote:I'm pretty sure the code that is raising the exception is within the try block, yet the exception still goes through.



No, it isn't. Check my subsequent answer in the other thread.
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic