Reputation: 968
Is there any reason to use the Guava one istead of the java.util implementation?
Upvotes: 4
Views: 3740
Reputation: 110054
One difference besides the fact that the Guava method predates the Java 7 one: the Guava method is called equal
while the Java method is called equals
. This is actually significant because it means the Java version can't be used with a static import. (Even ignoring that, I think equal
is a better name for a static method that takes two arguments and compares them for equality, while equals
is better for an instance method like Object.equals
.)
All that said, if you're on JDK7 you should probably use the java.util.Objects
version.
Upvotes: 7
Reputation: 8343
java.util.Objects
and its equals
method only exist since Java 7. The Guava version predates it. If you are using at least Java 7, there's no reason to use the Guava version.
Upvotes: 16