Java Program to convert float to String


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

Samual Sam
Samual Sam

Learning faster. Every day.

Updated on: 26-Jun-2020

187 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements