Convert from float to String in Java


To convert float to string, use the toString() method. It represents a value in a string.

Let’s say the following is our float.

float f = 0.9F;

Converting the float value to string.

String s = Float.toString(f);

Let us see the complete example to convert float to String in Java with output.

Example

 Live Demo

public class Demo {
   public static void main(String args[]) {
      float f = 0.9F;
      String s = Float.toString(f);
      System.out.println(s);
   }
}

Output

0.9

karthikeya Boyini
karthikeya Boyini

I love programming (: That's all I know

Updated on: 26-Jun-2020

9K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements