Solved

String to Float (Very important)

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

0
Comment
Question by:feup
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Why doesn't this text field show up on my Applet frame? 2 39
java example issue 5 63
Notify sent to other threads in Java 9 52
Java Inheritance super keyword use 8 66
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses

736 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