File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes about ==  equals Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "about ==  equals" Watch "about ==  equals" New topic
Author

about == equals

krussi rong
Ranch Hand

Joined: Jan 30, 2002
Posts: 62
Hi,
here is the question:
Double a = new Double(Double.NaN);
Double b = new Double(Double.NaN);
if(Double.NaN == Double.NaN)
System.out.println("True");
else
System.out.println("False");
if(a.equals(b))
System.out.println("True");
else
System.out.println("False");

So why the answer is False
True.
if Double.NaN == Double.NaN is False,
How the a.equals(b) comes True.
and I really don't know why Double.NaN == Double.NaN if False. and what is NaN?
Thanks
Krussi
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
Check out the API Spec for Double. In particular, check out the description of the equals() method.
Corey


SCJP Tipline, etc.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: about == equals
 
Similar Threads
Double doubt
Double Equals
Double.NaN
Double.NaN question
help..