I think == method can be used in Primitive datatypes and not objects.
The moment it becomes Double and not double it becomes an object and plus
NaN is a static value. Since you initialized to both the objects to a constant value it evaluates to true. Replace this with Double.NaN with 1.0
it will evaluate to the same result.
Originally posted by Marcos Vilela:
1: Double a = new Double(Double.NaN);
2: Double b = new Double(Double.NaN);
4: if( Double.NaN == Double.NaN )
9: if( a.equals(b) )
ok the first expression is false. But why the second one is true if the equals() compare the Double Value?