
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Double isNaN() method in Java
The java.lang.Double.isNan() method returns true if the specified number is a Not-a-Number (NaN) value, false otherwise.
Let’s say the following are our Double values.
Double val1 = new Double(3/0.); Double val2 = new Double(0/0.);
Now, we will use the isNan() method to check whether the number is a NaN or not.
val1.isNaN(); val2.isNaN()
The following is our final example.
Example
public class Demo { public static void main(String args[]) { Double val1 = new Double(3/0.); Double val2 = new Double(0/0.); System.out.println(val1.isNaN()); System.out.println(val2.isNaN()); } }
Output
false true
Advertisements