Less than 42 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

casting String into double  RSS feed

 
umut uzumcu
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Can anybody help me to sort this out please.

class..
{
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
sDB.coldDrinks(++coldDrinkNo,softDrinkPrice);
}


other class
{
Object/String getCap()
{
}
}


other class
{
coldDrinks(int, double)
{..}
}


Thanks in advance.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!