Here you can find the source of arrayHashCode(Object[] arr)
Parameter | Description |
---|---|
arr | array of objects, can contain <code>null</code>s |
public static int arrayHashCode(Object[] arr)
//package com.java2s; /*/*from ww w.j av a2s .c om*/ * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"). You may not use this file except in * compliance with the License. A copy of the License is available at * http://www.sun.com/ * * The Original Code is NetBeans. The Initial Developer of the Original * Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun * Microsystems, Inc. All Rights Reserved. */ public class Main { /** Compute hash code of array. * Asks all elements for their own code and composes the * values. * @param arr array of objects, can contain <code>null</code>s * @return the hash code * @see Object#hashCode */ public static int arrayHashCode(Object[] arr) { int c = 0; int len = arr.length; for (int i = 0; i < len; i++) { Object o = arr[i]; int v = o == null ? 1 : o.hashCode(); c += (v ^ i); } return c; } }