Convert float value to String

Asked

Viewed 436 times

2

I’m programming for android, and I’m trying to display a float value found by function getX() in a Toast, which only displays String values. How do I do this conversion?

2 answers

3


To convert a float value to string, you can use the method String.valueOf():

String str = String.valueOf(<valor float a ser convertido>);
  • Thanks! It worked perfectly!

  • 1

    @I’m glad you solved it. Just a hint for your next questions, to add the code with the problem, in this case it was possible to solve without seeing it, but depending on the problem you have in the future, it can be more complicated, to protect, always provide an excerpt ;)

0

You can use the class itself Float java:

String s = Float.toString(25.0f);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.