• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 177
  • Last Modified:

String to Float (Very important)

How can I convet a String to a float?

0
feup
Asked:
feup
1 Solution
 
omokCommented:
String floatStr = "1.234";
float floatValue = (new Float(floatStr)).floatValue();
OR
float floatValue = Float.valueOf(floatStr).floatValue();
0
 
diakovCommented:
Just a remark. Since you say 'important' you also have to put the suggested expression in a try ... catch block to process possible conversion exceptions. Also Float provides some means for testing for the special float numbers like infinity, nan, etc.

Cheers.
0
 
feupAuthor Commented:
Thank you very much. You just helped me finishing my project in the university.

Thanx
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now