90
Java Float isFinite() Method
The isFinite() method of Java Float class returns a Boolean value for the specified float object f. This method returns true if the argument passed is a finite floating-point number else returns false for NaN and infinity arguments.
Syntax:
Parameters:
The parameter passed is ‘f’ which is of float type.
Return Value:
This method returns a Boolean value for this float object.
- Returns true, if the argument passed is finite floating-point number.
- Returns false, if the arguments passed is Nan or infinity.
Example 1
Output:
Value returned is: false
Example 2
Output:
Returned result = true Returned result = true Returned result = false Returned result = false
Example 3
Output:
Error:(7, 23) java: float cannot be dereferenced
Here, float is a primitive data type. We cannot use its object to call Float class methods. Also isFinite() is a static method so, it should be called with the class name i.e. Float
Next TopicJava Float