Solved

String to Float (Very important)

Posted on 1998-10-20
3
168 Views
Last Modified: 2010-03-30
How can I convet a String to a float?

0
Comment
Question by:feup
3 Comments
 
LVL 1

Accepted Solution

by:
omok earned 20 total points
ID: 1226033
String floatStr = "1.234";
float floatValue = (new Float(floatStr)).floatValue();
OR
float floatValue = Float.valueOf(floatStr).floatValue();
0
 
LVL 8

Expert Comment

by:diakov
ID: 1226034
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
 

Author Comment

by:feup
ID: 1226035
Thank you very much. You just helped me finishing my project in the university.

Thanx
0

Featured Post

ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
groupSum6 challenge 6 86
eclipse package explorer vs project explorer view 2 132
Java DateChooser? 3 36
hibernate example for saving data 19 39
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question