In this example we will show how to tell if a double number is NaN use the isNaN() method of the Double class in Java.
Source Code
package com.beginner.examples;
public class DoubleIsNaNExamples {
public static void main(String[] args) {
Double double1 = new Double(Math.sqrt(-1));
// Use the isNaN() method to determine
System.out.println(double1.isNaN());
}
}
Output:
true