Java Hash Code Calculate hashCode(Object[] thisFields)

Here you can find the source of hashCode(Object[] thisFields)

Description

Helper function to compute hasCode by fields.

License

Open Source License

Parameter

Parameter Description
thisFields that used to count hash code.

Return

hash code computed from thisFields elements.

Declaration

public static int hashCode(Object[] thisFields) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**// w w  w .jav  a  2  s.c  om
     * Helper function to compute hasCode by fields.
     * 
     * @param thisFields that used to count hash code.
     * @return hash code computed from thisFields elements.
     */
    public static int hashCode(Object[] thisFields) {
        final int prime = 31;
        int result = 1;

        for (int i = 0; i < thisFields.length; i++) {
            Object field = thisFields[i];
            if (field != null) {
                result = prime * result + field.hashCode();
            }
        }
        return result;
    }
}

Related

  1. hashCode(Object... objects)
  2. hashCode(Object... objects)
  3. hashCode(Object... objs)
  4. hashCode(Object... toHash)
  5. hashCode(Object[] array)
  6. hashcode_old(final int[] array)
  7. hashCodeEps(double value)
  8. hashCodeForDoubleArray(double[] a)
  9. hashCodeLowerCase(Object... toHash)