Here you can find the source of hashCode(byte a[])
Parameter | Description |
---|---|
a | the array whose hash value to compute |
public static int hashCode(byte a[])
//package com.java2s; /*// www . j a v a 2 s .c om * JBoss, Home of Professional Open Source * Copyright 2005, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ public class Main { /** * Returns a hash code based on the contents of the specified array. For any * two <tt>byte</tt> arrays <tt>a</tt> and <tt>b</tt> such that * <tt>Arrays.equals(a, b)</tt>, it is also the case that * <tt>Arrays.hashCode(a) == Arrays.hashCode(b)</tt>. * * <p> * The value returned by this method is the same value that would be obtained * by invoking the {@link List#hashCode() <tt>hashCode</tt>} method on a * {@link List} containing a sequence of {@link Byte} instances representing * the elements of <tt>a</tt> in the same order. If <tt>a</tt> is * <tt>null</tt>, this method returns 0. * * @param a the array whose hash value to compute * @return a content-based hash code for <tt>a</tt> */ public static int hashCode(byte a[]) { if (a == null) { return 0; } int result = 1; for (int i = 0; i < a.length; i++) { result = 31 * result + a[i]; } return result; } }