Java Double - isFinite() Method
The java.lang.Double.isFinite() method is used to check whether the argument is a finite floating-point value or not. The method returns true if the argument is a finite floating-point value, false otherwise. The method returns false for NaN and infinity arguments.
Syntax
public static boolean isFinite(double d)
Parameters
d |
Specify the value to be tested. |
Return Value
Returns true if the argument is a finite floating-point value, false otherwise.
Exception
NA.
Example:
In the example below, the java.lang.Double.isFinite() method is used to check whether the argument is a finite floating-point value or not.
import java.lang.*; public class MyClass { public static void main(String[] args) { //creating double values double x = 5.2; double y = 1.0/0.0; double z = Double.NaN; //checking double values for finite System.out.println("Is x finite?: " + Double.isFinite(x)); System.out.println("Is y finite?: " + Double.isFinite(y)); System.out.println("Is z finite?: " + Double.isFinite(z)); } }
The output of the above code will be:
Is x finite?: true Is y finite?: false Is z finite?: false
❮ Java.lang - Double