目录

Set<K>keySet()

描述 (Description)

keySet()方法用于获取此映射中包含的键的基于标识的set视图。

声明 (Declaration)

以下是java.util.IdentityHashMap.keySet()方法的声明。

public Set<K> keySet()

参数 (Parameters)

NA

返回值 (Return Value)

方法调用返回此映射中包含的键的基于标识的set视图。

异常 (Exception)

NA

例子 (Example)

以下示例显示了java.util.IdentityHashMap.keySet()的用法

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 a set view
      Set nset = ihmap.keySet();
      System.out.println("Set view is: " + nset);
   }    
}

让我们编译并运行上面的程序,这将产生以下结果。

Set view is: [2, 3, 1]
↑回到顶部↑
WIKI教程 @2018