Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    IBM
    IBM is offline
    New Coder
    Join Date
    Jul 2002
    Posts
    42
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Java: NumberFormatException

    hi, this is a mystery to me...
    I've tried simplifying my code to see where the problems arise..but I can't make it any simpler..and the NumberFormat still won't accept
    0, or 0.0 as numbers..
    here's the code:
    try
    {
    Double.parseDouble(jTxtFAmount.getText());
    }
    catch(NumberFormatException ex)
    {
    jTxtArea.append("The amount entered is illegal\n"+ex.getMessage()+"\n");
    }

    I'd just as well say, you can't have a zero balance..becuase that's what the exception keeps catching...

    What can I do..any ideas?

  • #2
    Mega-ultimate member
    Join Date
    Jun 2002
    Location
    Winona, MN - The land of 10,000 lakes
    Posts
    1,855
    Thanks
    1
    Thanked 45 Times in 42 Posts
    Just a guess, but I think when you use parseDouble and parseInt, if the result returned is 0, it is equivilant to null. See if you can add something for the null exception.

  • #3
    IBM
    IBM is offline
    New Coder
    Join Date
    Jul 2002
    Posts
    42
    Thanks
    0
    Thanked 0 Times in 0 Posts
    hi, thanks for the reply.
    I forgot about this post..and just today remembered about it, and checked up on it.

    As it turns out, it wasn't my code that was wrong, but the class that I'm using won't accpet zero, it throws the numberformatexception.

    So thanks anyway.
    But it's remedied now.

    I will probably drop on by more often, as I'm learning java now.

    thank you


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •