How to convert Float to String in Java.

A string is a sequence of characters in computer programming that may be used as a literal constant or as a variable. The latter may allow for the mutation of its elements and the modification of their length, or it may be fixed (after creation). A string is a data type that is frequently implemented as an array data structure of bytes (or words) that records a succession of items, most commonly characters, using some character encoding. More generic arrays or another sequence (or list) data types and structures can also be represented using a string.

A floating-point data type is a group of data types that behave similarly and differ mainly in their domain sizes (the allowable values). Number values having fractional portions are represented via the floating-point family of data types. A mantissa and an exponent are the two integer values that they are stored as.  So today let us start with How to convert Float to String in Java.


What’s The Approach?


  • Import the java. util package into the class.


  • Now within the main method create a new object of Scanner class, for example, Scanner sc=new Scanner(System. in);


  • Use the Scanner class to get the input from the user.


  • Implement Float.toString(float_variable); to convert the float to String type


Also Read: How to Reverse a Number in Java using while loop


Java Program to convert Float to String in Java


 * TechDecode Tutorials
 * How to Covert Float to String
import java.util.*;
public class Float_to_String
    public static void main(String args[])
        // Creating an object of Scanner class
        Scanner sc= new Scanner(;
        // taking input from  the user
        System.out.print("Enter the Float value: ");
        float num=sc.nextFloat();
        // converting Float to string
        String s = Float.toString(num)  ;
        System.out.println("String is = " + s);


Leave a Reply

Your email address will not be published. Required fields are marked *