Solved

Convert String to Double

Posted on 2001-07-05
7
1,334 Views
Last Modified: 2008-02-26
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.
 
0
Comment
Question by:camasuvi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 1

Expert Comment

by:gtloafer
ID: 6254708
how about use the constructor Double(String)  in class Double ?

0
 

Author Comment

by:camasuvi
ID: 6254713
you mean
double newValue = Double(myString)   ?
0
 
LVL 1

Expert Comment

by:gtloafer
ID: 6254721
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
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Expert Comment

by:gtloafer
ID: 6254723
by the way what kind of string value are you passing ? ..Just curious thats why :-)

regards gtloafer
0
 
LVL 1

Expert Comment

by:poluru
ID: 6254742
hi,
Double.valueOf(myString).doubleValue();
its working nice...i have used it many times.
why its not working ??? just try once again...
0
 
LVL 1

Accepted Solution

by:
shahnazali earned 240 total points
ID: 6254769
use static method of Double
 double Double.parseDouble ( String s )

if u r not sure about your string that it contains double format number , catch NumberFormatException .

bye.

0
 

Expert Comment

by:anhphuongnn
ID: 6268553

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
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question