📜  如果 hashmap 只包含一个键,那么如何获取该键 - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:18.807000             🧑  作者: Mango

代码示例1
HashMap x = qu.remove();    
// This "qu" is a queue which is returning a Hashmap
// of type HashMap this hashmap contains
// only one key,value pair
Node node = x.keySet().iterator().next();
// here we are extracting that "KEY" of hashMap into variable of Node type