114
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
Output:
Result after being converted to float value = 5.0 Result after being converted to float value = 5.7
Example 2
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
Output:
Float value = -9.879799E19 Float value = -8276372.0
Next TopicJava Float