Link to home
Start Free TrialLog in
Avatar of camasuvi
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.
 
Avatar of gtloafer
gtloafer

how about use the constructor Double(String)  in class Double ?

Avatar of camasuvi

ASKER

you mean
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
by the way what kind of string value are you passing ? ..Just curious thats why :-)

regards gtloafer
hi,
Double.valueOf(myString).doubleValue();
its working nice...i have used it many times.
why its not working ??? just try once again...
ASKER CERTIFIED SOLUTION
Avatar of shahnazali
shahnazali

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial

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"+obj.toString());
  }

}


Best Regard

PhuongNguyen