Nathan Bubna wrote:
John J. Allison
...

       if (left.getClass().equals( right.getClass() ) )
       {
           return left.equals( right );
       }


shouldn't calling equals() itself be done before *anything* else? is there

Try new Float(1.0).equals(new Integer(1)). (Hint: The result is 'false'). I think .equals should be the last test. Numbers first, then Comparable and then .equals (which only applies to == and != anyway).

Peter

any real case where that would true, yet we'd want to return a different
result?

e.g.:

    if (left.equals(right))
    {
        return true;
    }
    else
...

it seems to me you only need to look at the class of the objects and/or do
conversions if equals() is false.

Nathan Bubna
[EMAIL PROTECTED]


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to