java.util.IdentityHashMap.values() 方法
描述
values() 方法用于获取此映射中包含的值的集合视图。
声明
以下是 java.util.IdentityHashMap.values() 方法的声明。
public Collection<V> values()
参数
NA
返回值
该方法调用返回此映射中包含的值的集合视图。
异常
NA
示例
下面的例子展示了 java.util.IdentityHashMap.values() 的用法。
package com.tutorialspoint;
import java.util.*;
public class IdentityHashMapDemo {
public static void main(String args[]) {
// create identity hash
IdentityHashMap ihmap = new IdentityHashMap();
// populate the ihmap
ihmap.put(1, "java");
ihmap.put(2, "util");
ihmap.put(3, "package");
System.out.println("Map values: " + ihmap);
System.out.println("Collection view of the map: " + ihmap.values());
}
}
让我们编译并运行上面的程序,这将产生以下结果.
Map values: {2=util, 3=package, 1=java}
Collection view of the map: [util, package, java]

