Home » Java Float floatValue() method with Examples

Java Float floatValue() method with Examples

by Online Tutorials Library

Java Float floatValue() method

The floatValue() method of Java Float class returns the float value of this object.

Syntax:

Parameters:

NA

Return Value:

This method returns the float value of the argument.

Example 1

Test it Now

Output:

Result after being converted to float value = 5.0  Result after being converted to float value = 5.7  

Example 2

Test it Now

Output:

Error:(12, 21) java: float cannot be dereferenced  

Here, float is a primitive data type. Its object can’t be used to call Float class method. If you do so, it will give you an error.

Example 3

Test it Now

Output:

Float value = -9.879799E19  Float value  = -8276372.0  

Next TopicJava Float

You may also like