GeeCON Prague 2014*
The moose likes Beginning Java and the fly likes From String to int Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "From String to int" Watch "From String to int" New topic
Author

From String to int

Mike Shn
Ranch Hand

Joined: May 26, 2001
Posts: 149
Hello
There any method in Java which allow to convert form float to int or from int to String or from String to double?
Thanks
Bill Krieger
Ranch Hand

Joined: Sep 27, 2001
Posts: 53
Originally posted by Mike Shn:
Hello
There any method in Java which allow to convert form float to int or from int to String or from String to double?
Thanks

float to int:
intVal = (int) floatVal;
int to String
stringVal = Integer.toString(intVal); // or
stringVal = "" + intVal;
String to double:
doubleVal = Double.parseDouble(stringVal);
Jessica Sant
Sheriff

Joined: Oct 17, 2001
Posts: 4313

Here's a perfect spot to introduce you to the Java API -- it shows you all the methods that you can use and how (its just a matter of knowing where to look for it)
JDK 1.3.1 API
In the upper left click the "java.lang" package
Then click on Float, Double and Integer --> you'll see all the methods that Bill mentioned:
float to int
int to String
String to Double


- Jess
Blog:KnitClimbJava | Twitter: jsant | Ravelry: wingedsheep
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: From String to int