In this example we will show how to check if a number is NaN in Java.
Source Code
package com.beginner.examples;
public class IsNaN {
public static void main(String[] args) {
Double num = new Double(0.0 / 0.0);
System.out.println(num.isNaN()); // check if a number is NaN
}
}
Output:
true