Set<Map.Entry<K,V>> entrySet()
描述 (Description)
entrySet()方法用于获取此映射中包含的映射的set视图。
声明 (Declaration)
以下是java.util.IdentityHashMap.entrySet()方法的声明。
public Set<Map.Entry<K,V>> entrySet()
参数 (Parameters)
NA
返回值 (Return Value)
方法调用返回此映射中包含的标识映射的set视图。
异常 (Exception)
NA
例子 (Example)
以下示例显示了java.util.IdentityHashMap.entrySet()的用法
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");
// create entry set from the map
Set enset = ihmap.entrySet();
System.out.println("Set view of the map: " + enset);
}
}
让我们编译并运行上面的程序,这将产生以下结果。
Set view of the map: [2=util, 3=package, 1=java]