Goeman Stefan wrote:
> I know, this is not really a question about Debian.
You got that right.
> The question is actually very simple. I want to convert a
> string to a double.
> There is a method in the java.lang.Double named
> When I insert a line like
> double d = Double.parseDouble(x);
> in my program, I get the error:
> Method parseDouble(java.lang.String) not found in class java.lang.Double
This method is only in java.lang.Double since JDK 1.2. You must have an earlier
> There is also another method in the java.lang.Double class that should do
> the same,
> i.e. method valueOf
> Now, when I insert a line like
> double d = Double.valueOf(x);
> in the program, i get the error:
> Incompatible type for declaration. Can't convert java.lang.Double to double.
Yup, because Double.valueOf() returns type java.lang.Double, not simply double. What
you want is:
double d = Double.valueOf(x).doubleValue();
> in the program,
> (Casting does not solve this problem)
Nope. There's no such thing as
such as there _might_ be if this were C++, which it isn't.
> Does anybody know what is going wrong??
Jens B. Jorgensen
- Re: java
- From: Thomas Kirsch <email@example.com>
- From: Goeman Stefan <Stefan.Goeman@siemens.atea.be>