public final class Objects extends Object
Object
.public static boolean equal(@Nullable Object a, @Nullable Object b)
true
if a
and b
are both null.
true
if a
and b
are both non-null and they are
equal according to Object.equals(Object)
.
false
in all other situations.
This assumes that any non-null objects passed to this function conform
to the equals()
contract.
public static int hashCode(Object... objects)
Arrays.hashCode(Object[])
.
This is useful for implementing Object.hashCode()
. For example,
in an object that has three properties, x
, y
, and
z
, one could write:
public int hashCode() { return Objects.hashCode(getX(), getY(), getZ()); }Warning: When a single object is supplied, the returned hash code does not equal the hash code of that object.
Copyright © 2006-2012 Google, Inc.. All Rights Reserved.