我有这个字段:
HashMap<String, HashMap> selects = new HashMap<String, HashMap>();
对于每个 Hash<String, HashMap>
我需要创建一个 ComboBox
,其项目是 HashMap <String, **HashMap**>
的值(恰好是 HashMap 本身) .
通过(非功能性)演示:
for (int i=0; i < selects.size(); i++) {
HashMap h = selects[i].getValue();
ComboBox cb = new ComboBox();
for (int y=0; y < h.size(); i++) {
cb.items.add(h[y].getValue);
}
}
最佳答案
我知道我有点晚了,但我也会分享我所做的,以防它帮助其他人:
HashMap<String, HashMap> selects = new HashMap<String, HashMap>();
for(Map.Entry<String, HashMap> entry : selects.entrySet()) {
String key = entry.getKey();
HashMap value = entry.getValue();
// do what you have to do here
// In your case, another loop.
}
关于java - 如何为每个 HashMap ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4234985/