This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes From String to int Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Reply 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://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: From String to int
 
Similar Threads
parse int to string???help!!!!
Parameters and Function
JButton Syntax Question
substring method with two params
Converting a String to an int