containsKey(Object key)%uA0方法是用来测试指定的对象引用是否为此标识哈希映射中的键。
声明
以下是java.util.IdentityHashMap.containsKey()方法的声明。
public boolean containsKey(Object key)
参数
-
key--这是要进行检查的键。
返回值
该方法调用返回true,如果指定的对象引用是此映射的一个键。
异常
-
NA
例子
下面的例子显示java.util.IdentityHashMap.containsKey()方法的使用
package com.yiibai 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 &apos3&apos exists: " + isavailable) } }
现在编译和运行上面的代码示例,将产生以下结果。
Is key &apos3&apos exists: true