This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Features new in Java 7 and the fly likes equals and hashCode of Java7 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Features new in Java 7
Bookmark "equals and hashCode of Java7" Watch "equals and hashCode of Java7" New topic
Author

equals and hashCode of Java7

nimo frey
Ranch Hand

Joined: Jun 28, 2008
Posts: 580
I have used Google Guava for overriding hashCode/equals-Method via com.google.common.base.Objects Methods.

Java 7 provides the Objects.hash and Objects.equals-Method.

Are guava (hashCode, equals) and java objects (hash, equals) the same?

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19654
    
  18

They definitely serve the same purpose. These methods have been in demand for years; not only Google, but also Apache Commons Lang has them. Oracle (or actually Sun) should have added them long before.
You need to check the source code of both to see whether or not they are implemented the same. Oracle's code can be found in the src.zip file inside the JDK folder.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
nimo frey
Ranch Hand

Joined: Jun 28, 2008
Posts: 580
Okay, thank you, you are right. It is the same !
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19654
    
  18

You're welcome, and thanks for verifying
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: equals and hashCode of Java7
 
Similar Threads
Detecting Duplicates in Hashmap
Doubt Regarding HashSet
HashSet ordering
map method containsKey
Need Information about equals() anf hashcode() in java