Lambdas and serialization

Mark Thornton mthornton at optrak.co.uk
Wed Nov 10 06:03:29 PST 2010


On 10/11/2010 13:16, Llewellyn Falco wrote:
> I just realized this is a mistake!
>
> Comparable will not work properly without the Equals method
> being overridden.
>
> Namely, if you have two object a, b you will get
> a.compareTo(b) == 0
> but
> a.equals(b) == false
 From the JavaDoc for Comparable:
"It is strongly recommended (though not required) that natural orderings 
be consistent with equals."

Note it is a recommendation not a requirement. BigDecimal is an example 
where the natural ordering is not consistent with equals.

Mark Thornton



More information about the lambda-dev mailing list