[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Convert String to Double

Posted on 2001-07-05
7
Medium Priority
?
1,350 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
Independent Software Vendors: 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 720 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

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses

656 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