目录

int hashCode()

描述 (Description)

java.lang.Short.hashCode()方法返回此Short的哈希码。

声明 (Declaration)

以下是java.lang.Short.hashCode()方法的声明

public int hashCode()

参数 (Parameters)

NA

返回值 (Return Value)

此方法返回此对象的哈希码值。

异常 (Exception)

NA

例子 (Example)

以下示例显示了java.lang.Short.hashCode()方法的用法。

package com.iowiki;
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
↑回到顶部↑
WIKI教程 @2018