posted 23 years ago
I think the primitives behave according to IEEE-754 standard, but
the Wrapper has to behave according to the contract of equals method in Object class. This is even clearer in:
Integer iw = new Integer(10);
Float fw = new Float(10.0f);
if (iw.equals(fw))
System.out.println("Equal");
The equals could have returned true. But the contract of equals doesn't allow it. If you check,
if(a.doubleValue() == b.doubleValue())
System.out.println("True doubleValue");
else
System.out.println("False doubleValue");
it returns false.