Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Float to string n String to Float ex

 
Sham Jowsaki
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
float f = 3.0f;
String s = String.valueOf(f);
// This can throw NumberFormatException
f = Float.parseFloat(s);
 
Ransika deSilva
Ranch Hand
Posts: 524
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use
Strnig x = Float.toString(float a) also to convert a float to a string..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic