java.util.Hashtable.hashCode() 方法
描述
hashCode() 方法用于根据 Map 接口中的定义获取此 Map 的哈希码值。
声明
以下是 java.util.Hashtable.hashCode() 方法的声明。
public int hashCode()
参数
NA
返回值
方法调用返回此对象的哈希码值。
异常
NA
示例
下面的例子展示了 java.util.Hashtable.hashCode() 的用法。
package com.tutorialspoint;
import java.util.*;
public class HashTableDemo {
public static void main(String args[]) {
// create hash table
Hashtable htable1 = new Hashtable();
// put values in table
htable1.put(1, "A");
htable1.put(2, "B");
htable1.put(3, "C");
htable1.put(4, "D");
// get the hash code value
System.out.println("Hash code value is :"+htable1.hashCode());
}
}
让我们编译并运行上面的程序,这将产生以下结果.
Hash code value is :256

