Java Hash Code Calculate hashCode(Object[] array)

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

Description

hash Code

License

Open Source License

Declaration

public static int hashCode(Object[] array) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2000, 2011 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:/*from ww  w.  j a  v a2s.com*/
 *     IBM Corporation - initial API and implementation
 *     daolaf@gmail.com - Contribution for bug 3292227
 *******************************************************************************/

public class Main {
    public static int hashCode(Object[] array) {
        int prime = 31;
        if (array == null) {
            return 0;
        }
        int result = 1;
        for (int index = 0; index < array.length; index++) {
            result = prime * result + (array[index] == null ? 0 : array[index].hashCode());
        }
        return result;
    }
}

Related

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