Class Objects

    • Method Detail

      • hashCode

        public static int hashCode(@Nullable Object @Nullable ... objects)
        Generates a hash code for multiple values. The hash code is generated by calling Arrays.hashCode(Object[]). Note that array arguments to this method, with the exception of a single Object array, do not get any special handling; their hash codes are based on identity and not contents.

        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.

        Note for Java 7 and later: This method should be treated as deprecated; use Objects.hash(java.lang.Object...) instead.