This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes casting String into double Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "casting String into double" Watch "casting String into double" New topic

casting String into double

umut uzumcu
Ranch Hand

Joined: Jan 10, 2007
Posts: 43
Can anybody help me to sort this out please.

Object p=pList.getCap(); //either this
String s=pList.getCap(); //or this

//here I need to cast the Object or String (any will do) into double
//to send it as an argument to coldDrinks(int, double) method

other class
Object/String getCap()

other class
coldDrinks(int, double)

Thanks in advance.
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24183

Well, the question is, what does getCap() actually return? Is it a String? If so, look at the static parseDouble() method in the java.lang.Double class.

[Jess in Action][AskingGoodQuestions]
I agree. Here's the link:
subject: casting String into double
Similar Threads
Question about Boxing
who can tell what is the method parseInt( )?
TableModel question
Setting Cell Editors in J(X)Table
Having problems with an arrays assignment