Hi guys,
I'd like to parse the String to double value.
But String has a minus value such as "-1", "-2"...
I used the Double.parseDouble(String s); method.
The example code is
String s = "-1";
double d = Double.parseDouble(s);
This doesn't seem to work properly.
How can I correctly parse the minus value?
Lee Weiner - 04 Nov 2006 02:30 GMT
>Hi guys,
>I'd like to parse the String to double value.
[quoted text clipped - 8 lines]
>This doesn't seem to work properly.
>How can I correctly parse the minus value?
What do you mean, it doesn't seem to work properly?
It works perfectly for me.
public class ParseDouble
{
public static void main( String[] args )
{
String s = "-1";
double d = Double.parseDouble( s );
System.out.println( d );
}
}
Displays -1.0
Lee Weiner
lee AT leeweiner DOT org