Home » Java Float isFinite() method with Examples

Java Float isFinite() method with Examples

by Online Tutorials Library

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

Test it Now

Output:

Value returned is: false  

Example 2

Test it Now

Output:

Returned result = true  Returned result = true  Returned result = false  Returned result = false  

Example 3

Test it Now

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

You may also like