Java.lang.Float.toString() Method

Advertisements


Description

The java.lang.Float.toString() method returns a string representation of this Float object.

Declaration

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

public String toString()

Parameters

  • NA

Return Value

This method returns a string representation of this object.

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("30.54");
   
     // returns a string representation
     String retval = f.toString();
     System.out.println("Value = " + retval);
   }
}   

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

Value = 30.54



Advertisements
Advertisements