Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Beginning Java
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Beginning Java
Enum class - equals() and hashCode() ?
kri shan
Ranch Hand
Posts: 1491
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Whether enum classes need object's equals() and hashCode() ?
Campbell Ritchie
Marshal
Posts: 79177
377
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Start in the
Java™ Language Specification
. Remember enum members are singletons, so == is adequate as a
test
for equality.
Rob Spoor
Sheriff
Posts: 22783
131
I like...
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Besides, all enum classes implicitly extend java.lang.Enum 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 - OCEJPAD 6
How To Ask Questions
How To Answer Questions
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
HashSet ordering
map method containsKey
On Sets
what is hashcode and equals contract?
Cannot understand enum class syntax
More...