Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to for each the hashmap? [duplicate]

Tags:

java

I have this field:

HashMap<String, HashMap> selects = new HashMap<String, 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**>.

By way of (non-functioning) demonstration:

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);     } } 
like image 572
Mediator Avatar asked Nov 20 '10 20:11

Mediator


1 Answers

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. } 
like image 136
Cyril N. Avatar answered Nov 25 '22 18:11

Cyril N.