aspose file tools*
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 Java 8 in Action this week in the Java 8 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: 19557
    
  16

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: 19557
    
  16

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
Need Information about equals() anf hashcode() in java
Doubt Regarding HashSet
map method containsKey
HashSet ordering