Tutorialspoint

1 Answer
Samual Sam
, 0 Views

The valueOf() method is used in Java to convert float to string.

Let’s say we have the following float value.

float val = 10.18465F;

Converting the above float value to string.

String.valueOf(val);

Example

Live Demo

public class Demo {
   public static void main(String[] args)  {
      float val = 98.18465F;
      // converting float to String
      String str = String.valueOf(val);
      System.out.println("String: "+str);
   }
}

Output

String: 98.18465

Advertisements