Java Program to convert float to String

Java 8Object Oriented ProgrammingProgramming

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
raja
Published on 07-Dec-2018 09:53:18
Advertisements