java.util.IdentityHashMap.containsKey() 方法
描述
containsKey(Object key) 方法用于测试指定的对象引用是否是此标识哈希映射中的键。
声明
以下是 java.util.IdentityHashMap.containsKey() 方法的声明。
public boolean containsKey(Object key)
参数
key − 这是可能要检查的键。
返回值
如果指定的对象引用是此映射中的键,则方法调用返回"true"。
异常
NA
示例
下面的例子展示了 java.util.IdentityHashMap.containsKey() 的用法。
package com.tutorialspoint;
import java.util.*;
public class IdentityHashMapDemo {
public static void main(String args[]) {
// create identity hash map
IdentityHashMap ihmap = new IdentityHashMap();
// populate the map
ihmap.put(1, "java");
ihmap.put(2, "util");
ihmap.put(3, "package");
// check if key 3 exists
boolean isavailable = ihmap.containsKey(3);
System.out.println("Is key '3' exists: " + isavailable);
}
}
让我们编译并运行上面的程序,这将产生以下结果.
Is key '3' exists: true

