Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Converting String to double

  Asked By: Adelina    Date: Jan 21    Category: Java    Views: 833
  

Can anyone out there, pls help. I need to convert
String to a double value...public class
test{public static void main (String [] args){String
stringValue = new String("147.82");Double tempValue =
Double.valueOf(stringValue);double doubleValue =
doubleValue(tempValue);}}But I got error during compilation. The
following is
the error. Pls helpd:\Program Files\Xinox
Software\JCreator LE\MyProjects\test.java:7: cannot resolve
symbolsymbol : method doubleValue
(java.lang.Double)location: class testdouble doubleValue =
doubleValue(tempValue);Anyone had any idea why this is so, cos i follow
it
exactly from the book.

Share: 

 

2 Answers Found

 
Answer #1    Answered By: Maurice Hanson     Answered On: Jan 21

Change the line:double doubleValue =
doubleValue(tempValue);To:double doubleValue =
tempValue.doubleValue();The
doubleValue() method  is an instance method which you use on
your tempValue which is an instance of the Double
class.

 
Answer #2    Answered By: Bellona Lopez     Answered On: Jan 21

I had been scratch my skull for more than a week
now...I am truly grateful

 
Didn't find what you were looking for? Find more on Converting String to double Or get search suggestion and latest updates.




Tagged: