boolean containsValue(Object value)
描述 (Description)
containsValue(Object value)方法用于测试指定的对象引用是否是此标识哈希映射中的值。
声明 (Declaration)
以下是java.util.IdentityHashMap.containsValue()方法的声明。
public boolean containsValue(Object value)
参数 (Parameters)
value - 这是要检查的可能值。
返回值 (Return Value)
如果此映射将一个或多个键映射到指定的对象引用,则方法调用将返回“true”。
异常 (Exception)
NA
例子 (Example)
以下示例显示了java.util.IdentityHashMap.containsValue()的用法
package com.iowiki;
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 value exists at key 3
boolean isavailable = ihmap.containsValue(3);
System.out.println("Is value exists at key '3': " + isavailable);
}
}
让我们编译并运行上面的程序,这将产生以下结果。
Is value exists at key '3': false