camasuvi
asked on
Convert String to Double
Hi all,
I am using JSP and i need to convert string to double
Double.valueOf(mystring) does not work..
Any suggestion will be appreciated.
I am using JSP and i need to convert string to double
Double.valueOf(mystring) does not work..
Any suggestion will be appreciated.
how about use the constructor Double(String) in class Double ?
ASKER
you mean
double newValue = Double(myString) ?
double newValue = Double(myString) ?
Well not quite ....rather I was thinking like this :-
Double dWrap = new Double("200");
double dVal = dWrap.doubleValue(); //this is because dWrap is an object wrapper for the primitive type double ..
regards gtloafer
Double dWrap = new Double("200");
double dVal = dWrap.doubleValue(); //this is because dWrap is an object wrapper for the primitive type double ..
regards gtloafer
by the way what kind of string value are you passing ? ..Just curious thats why :-)
regards gtloafer
regards gtloafer
hi,
Double.valueOf(myString).d oubleValue ();
its working nice...i have used it many times.
why its not working ??? just try once again...
Double.valueOf(myString).d
its working nice...i have used it many times.
why its not working ??? just try once again...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi,
You can try this code. is it you need?
import java.io.*;
import java.lang.*;
public class StringToDouble {
static void main(String agrs[]) {
Object obj = new Double("1.101");
System.out.println("test"+
}
}
Best Regard
PhuongNguyen