Java.lang.Short.hashCode() 方法
描述
java.lang.Short.hashCode() 方法返回此 Short 的哈希码。
声明
以下是 java.lang.Short.hashCode() 方法的声明。
public int hashCode()
参数
NA
返回值
此方法返回此对象的哈希码值。
异常
NA
示例
下面的例子展示了 java.lang.Short.hashCode() 方法的使用。
package com.tutorialspoint;
import java.lang.*;
public class ShortDemo {
public static void main(String[] args) {
// create short object and assign value to it
short shortNum1 = 150;
Short ShortObj1 = new Short(shortNum1);
// returns hashcode
int hcode = ShortObj1.hashCode();
System.out.println("Hashcode for this Short ShortObj1 = " + hcode);
}
}
让我们编译并运行上面的程序,这将产生下面的结果 −
Hashcode for this Short ShortObj1 = 150

