"Shh, Zog....here come one Now!"
"Shh, Zog....here come one Now!"
"Shh, Zog....here come one Now!"
Originally posted by Dirk Schreckmann:
If you'd like, we could discuss the merits of extending different types of Exceptions and why one might favor the use of a standard Exception over creating a new type.
You're likely actually using Double.parseDouble( String ) . This method can handle "0" or "0.0" just fine. How is it exactly that you are having a problem in this regard?I am using
Double.ParseDouble(jTextFiled.getText());
NumberFormat seems to not like the number '0'.
"Shh, Zog....here come one Now!"
Originally posted by Dirk Schreckmann:
You're likely actually using Double.parseDouble( String ) . This method can handle "0" or "0.0" just fine. How is it exactly that you are having a problem in this regard?
[ November 05, 2002: Message edited by: Dirk Schreckmann ]
"Shh, Zog....here come one Now!"
You could associate two catch blocks with one try block, but each catch block would have to catch different types of Exceptions.could I use two catch{} statements to test for neg numbers, and strings?
My mistake. I misread the class mentioned in your post.well, the input works, the numbers are parsed and everything goes as planned.
But if in the input field I use '0', or '0.0', the NumberFormatException displays my error message.
I don't know why it does, but it catches zero as not being a number, I think...
I've begun a new thread in The Intermediate Forum. Let's continue such a conversation over there...Originally posted by Volodymyr Shram:
So, you want to say, that it is better to use standard Exception over creating a new type (extended Exception)? Would you so kind to explain why do you think so, or start new thread for this discussion -- it's very interesting really.
Originally posted by Dirk Schreckmann:
My mistake. I misread the class mentioned in your post.
[ November 05, 2002: Message edited by: Dirk Schreckmann ]
"Shh, Zog....here come one Now!"
Originally posted by Dirk Schreckmann:
So, you could say
if (test fails)
throw new NumberFormatException( "A new account with a negative balance cannot be created." );
I realize that you may be already familiar with some of the arguments against a design such as this one, but... well, what do you think might be a better design?
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Originally posted by Dirk Schreckmann:
I've begun a new thread in The Intermediate Forum. Let's continue such a conversation over there...
Originally posted by Ilja Preuss:
If you are using JDK1.4+, you might want to take a look at JFormattedTextField...
"Shh, Zog....here come one Now!"
Originally posted by Drake Silver:
huh?
what exactly is that?
Is it a method for TextFields?
How would I use it?
thanks
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
"Shh, Zog....here come one Now!"
"Shh, Zog....here come one Now!"
I think there may be some confusion about what a NumberFormatException object is and what a NumberFormat object is. To be very clear - a NumberFormat object is not a NumberFormatException. I see no where in your code where you are making use of a NumberFormat object.So, after all this reading I'm beginning to understand Numberformat a little more.
You wouldn't use either NumberFormat or NumberFormatException to check for a negative number. You may want to use the if (test fails) then throw new NumberFormatException( "error message" ) construct as suggested previously.why would I use it to check for negative numbers, they are after all still numbers. Wouldn't I instead want to use If then else statements to check for negative numbers..doesn't that make more sense.
You should be able to parse "0" or "0.0" into a number. An exception isn't catching anything. Perhaps an exception is being created and thrown when something that tries to do something fails.I'd just as well say, you can't have a zero balance..because that's what the exception keeps catching.
"Shh, Zog....here come one Now!"
"Shh, Zog....here come one Now!"
I love a woman who dresses in stainless steel ... and carries tiny ads:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|