VOOZH about

URL: https://www.geeksforgeeks.org/java/double-isnan-method-in-java-with-examples/

⇱ Double isNaN() method in Java with examples - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Double isNaN() method in Java with examples

Last Updated : 11 Jul, 2025
The isNaN() method of Java Double class is a built in method in Java returns true if this Double value or the specified double value is Not-a-Number (NaN), or false otherwise. Syntax:
public boolean isNaN()
 or
public static boolean isNaN(double val)
Parameters: The function accepts a single parameter val which specifies the value to be checked when called directly with the Double class as static method. The parameter is not required when the method is used as instance method. Return Value: It returns true if the val is NaN else it return false. Below programs illustrate isNaN() method in Java: Program 1:
Output:
Infinity is not NaN
NaN is NaN
Program 2:
Output:
Infinity is not NaN
NaN is NaN
Reference: https://docs.oracle.com/javase/7/docs/api/java/lang/Float.html#isNaN()
Comment