如何为每个hashmap? [英] How to for each the hashmap?

查看:111
本文介绍了如何为每个hashmap?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个字段:

HashMap<String, HashMap> selects = new HashMap<String, HashMap>();

对于每个 Hash< String,HashMap> 我需要创建一个 ComboBox ,其项目是 HashMap< String,** HashMap *的值(恰好是HashMap本身) *>

For each Hash<String, HashMap> I need to create a ComboBox, whose items are the value (which happens to be a HashMap itself) of HashMap <String, **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);
    }
}


推荐答案

我知道我有点迟到了,但是我会分享我做的事情,以防它帮助其他人:

I know I'm a bit late for that one, but I'll share what I did too, in case it helps someone else :

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.
}

这篇关于如何为每个hashmap?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆