java.util.Arrays.hashCode(short[])%uA0方法返回基于指定数组的内容的哈希码。对于任何两个short数组a和b,使得Arrays.equals(a,b),正如Arrays.hashCode(a)== Arrays.hashCode(b)。
声明
以下是java.util.Arrays.hashCode()方法的声明
public static int hashCode(short[] a)
参数
-
a%uA0-- 这是用于计算哈希值的数组。
返回值
此方法返回一个基于内容的哈希码。
异常
- NA
例子
下面的示例演示java.util.Arrays.hashCode()方法的用法。
package com.yiibai import java.util.Arrays public class ArrayDemo { public static void main(String[] args) { // initializing short array short[] sval = new short[] { 2 } // hashcode for value1 int retval = sval.hashCode() // printing hash code value System.out.println("The hash code of value1 is: " + retval) // value2 for short array sval=new short[] { 30, 50 } // hashcode for value2 retval=sval.hashCode() // printing hash code value System.out.println("The hash code of value2 is: " + retval) } }
让我们来编译和运行上面的程序,这将产生以下结果:
The hash code of value1 is: 4072869 The hash code of value2 is: 1671711