Facebook Page Twitter Page LinkedIn Page
× Java.lang Package Classes


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 below example, 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 = new Double(1.0/0.0);
    double z = new 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