public final class Objects extends Object
java.util.Objects#hash(Object...) and java.util.Objects#hashCode() from Java 7 into Java 6.| Constructor and Description |
|---|
Objects() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
equals(Object a,
Object b)
Returns
true if the arguments are equal to each other and false otherwise. |
static int |
hash(Object... values)
Generates a hash code for a sequence of input values.
|
static int |
hashCode(Object o)
Returns the hash code of a non-
null argument and 0 for a null argument. |
public static final int hash(Object... values)
Arrays.hashCode(Object[]).
This method is useful for implementing Object.hashCode() on objects containing multiple fields. For example, if an object that has three fields,
x, y, and z, one could write:
@Override
public int hashCode() {
return Objects.hash(x, y, z);
}
values - the values to be hashedArrays.hashCode(Object[]),
List.hashCode()public static final int hashCode(Object o)
null argument and 0 for a null argument.o - an objectnull argument and 0 for a null argumentObject.hashCode()public static final boolean equals(Object a, Object b)
true if the arguments are equal to each other and false otherwise. Consequently, if both arguments are null, true
is returned and if exactly one argument is null, false is returned. Otherwise, equality is determined by using the equals method of the first argument.a - an objectb - an object to be compared with a for equalitytrue if the arguments are equal to each other and false otherwiseObject.equals(Object)Copyright © 2008-2014 The java.net WebDAV Project. All Rights Reserved.