方法hashCode(int [] a)在Java中做什么?

 java.util.Arrays类的 hashCode(int [])方法基于指定数组的内容返回哈希码。对于任意两个非空int数组a和b,例如Arrays.equals(a,b),Arrays.hashCode(a)== Arrays.hashCode(b)也是这种情况。

示例

import java.util.Arrays;

public class ArrayDemo {
   public static void main(String[] args) {
      int[] ival = new int[] { 3, 5 };
      int retval = ival.hashCode();
      System.out.println("The hash code of value1 is: " + retval);
      ival = new int[] { 19, 75 };
      retval = ival.hashCode();
      System.out.println("The hash code of value2 is: " + retval);
   }
}

输出结果

The hash code of value1 is: 4072869
The hash code of value2 is: 1671711