*
The moose likes Beginning Java and the fly likes Float to string n String to Float ex Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Float to string n String to Float ex" Watch "Float to string n String to Float ex" New topic
Author

Float to string n String to Float ex

Sham Jowsaki
Ranch Hand

Joined: May 22, 2001
Posts: 146
Hi All,
Can you pls give me an example of data conversion of
float to string
string to float
Thanks
Jowsaki
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

float f = 3.0f;
String s = String.valueOf(f);
// This can throw NumberFormatException
f = Float.parseFloat(s);


[Jess in Action][AskingGoodQuestions]
Ransika deSilva
Ranch Hand

Joined: Feb 18, 2003
Posts: 524
You can use
Strnig x = Float.toString(float a) also to convert a float to a string..


SCJP 1.4, SCMAD 1.0<br />SCWCD, SCBCD (in progress)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Float to string n String to Float ex