Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

From String to int

 
Mike Shn
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic