Solved

Convert String to Double

Posted on 2001-07-05
7
1,337 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
Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
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 will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

724 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