Java.lang.Float.toString() Method

Advertisements


Description

The java.lang.Float.toString(float f) method returns a string representation of the float argument f.

Declaration

Following is the declaration for java.lang.Float.toString() method

public static String toString(float f)

Parameters

  • f -- This is the float to be converted.

Return Value

This method returns a string representation of the argument.

Exception

  • NA

Example

The following example shows the usage of java.lang.Float.toString() method.

package com.tutorialspoint;

import java.lang.*;

public class FloatDemo {

   public static void main(String[] args) {

     Float f = new Float("32.74");
   
     // returns a string representation of the float argument
     String retval = Float.toString(f);
     System.out.println("Value = " + retval);
   }
}   

Let us compile and run the above program, this will produce the following result:

Value = 32.74



Advertisements
Advertisements