我正在尝试从映射中对 Keyset 进行 itreate,但我的程序无法识别关键字 KeyType:
我正在使用 Oracle Java 文档中提到的以下代码 Here
for (KeyType key : outputMap.keySet())
System.out.println(key);
最佳答案
文档中的代码是伪代码。将 KeyType
替换为您作为键存储在 Map
中的类型。
例如:
Map<Integer, String> map = new HashMap<>();
for (Integer key : map.keySet()) {
//..
}
关于java - MAP Keyset 不工作 - 无法识别关键字 KeyType?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16169424/