A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Enum class - equals() and hashCode() ?
Joined: Apr 08, 2004
Dec 18, 2010 20:38:46
Whether enum classes need object's equals() and hashCode() ?
Joined: Oct 13, 2005
Dec 19, 2010 02:04:10
Start in the
Java™ Language Specification
. Remember enum members are singletons, so == is adequate as a
Joined: Oct 27, 2005
Dec 19, 2010 03:12:47
Besides, all enum classes implicitly extend
which has final implementations of both. equals uses == and hashCode uses Object.hashCode. Try overriding them in any enum and you'll get a compiler error.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions
How To Answer Questions
I agree. Here's the link:
subject: Enum class - equals() and hashCode() ?
Cannot understand enum class syntax
what is hashcode and equals contract?
map method containsKey
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014