• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

equals and hashCode of Java7

 
nimo frey
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20669
65
Chrome Eclipse IDE Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
nimo frey
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay, thank you, you are right. It is the same !
 
Rob Spoor
Sheriff
Pie
Posts: 20669
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome, and thanks for verifying
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic