This week's giveaway is in the Android forum. We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line! See this thread for details.

I guess, its similar like when u comapre two String objects. a and b being two different objects ( created using new) points to different locations so gives false in the first case (==) . and in the second case (equals), vlaues are being compared so yields True. Correct me if i am wrong. Thanx

lashkar, java.lang.Double has the following meaning for equals: Compares this object against the specified object. The result is true if and only if the argument is not null and is a Double object that represents a double that has the identical bit pattern to the bit pattern of the double represented by this object. Also as swati said it overrides the equals of the java.lang.Object and hence acts similar to java.lang.String.

Lashkar, the first comparison concerns the static values for Double.NaN (not the a & b instances you've created). I believe the API states that Double.Nan != Double.NaN. Two values which are not numbers don't necessarily equal each other, which is why Double.NaN == Double.NaN will always return false.

Hi Azaman, Here's from JDK1.3 API docs quote: ================================================================ Note that in most cases, for two instances of class Double, d1 and d2, the value of d1.equals(d2) is true if and only if d1.doubleValue() == d2.doubleValue()

also has the value true. However, there are two exceptions: If d1 and d2 both represent Double.NaN, then the equals method returns true, even though Double.NaN==Double.NaN has the value false. If d1 represents .0 while d2 represents -0.0, or vice versa, the equal test has the value false, even though .0==-0.0 has the value true. This allows hashtables to operate properly. ================================================================ - eric

Hi, This is from JLS. I think this will be help for this discussion

NaN is unordered, so the numerical comparison operators <, <=, >, and >= return false if either or both operands are NaN (�15.20.1). The equality operator == returns false if either operand is NaN, and the inequality operator != returns true if either operand is NaN (�15.21.1). In particular, x!=x is true if and only if x is NaN, and (x<y) == !(x>=y) will be false if x or y is NaN.

Vanitha. [This message has been edited by Vanitha Sugumaran (edited July 15, 2001).]

Hi lashkar, Please read the JavaRanch Name Policy and re-register using a name that complies with the rules. Thanks for your cooperation. ------------------ Jane Griscti Sun Certified Programmer for the Java� 2 Platform