Java String valueOf(float f) method example

HQ » Java Tutorial » java.lang » String » valueOf(float f) method example
Java String valueOf(float f) method example 2018-02-19T13:14:40+00:00

java.lang.String valueOf(float f)

Description :

This java tutorial shows how to use the valueOf(float f) method of String class of java.lang package. This method returns a string representation of float data type. This will yield the same result as Float.toString(float).

Method Syntax :

public static String valueOf(float f)

Parameter Input :

DataType Parameter Description
float f method parameter which we are interested to get the string equivalent

Method Returns :

The String valueOf() method with argument float returns a new String object which corresponds to the string representation of the method argument.

Compatibility Version :

Since the beginning

Exception :


Discussion :

The string valueOf(float f) method is simply to get a String equivalent of float method parameter. This method be statically accessed which means we should call the method like String.valueOf(float f).

Java Code Example :

This example source code demonstrates the use of valueOf(float f) of String class. Below are different examples of getting a value of float. As you would noticed we have used the unboxing functionality to transform a Float object into float primitive datatype and then get the string equivalent using the valueOf method.

Sample Output :

Running the valueOf() method example source code of String class will give you the following output

java string indexOf(float) method example

java string indexOf(float) method example

Exception Scenario :


Suggested Reading List :

References :


Contact Info


Our Goal

JavaTutorialHQ aims to to be The Ultimate Guide on Java with hundreds of examples from basic to advance Topics.

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.