0

I have constructed a series of nested ConcurrentHashMaps initially with

private final ConcurrentHashMap<String, Object> allInOne = 
    new ConcurrentHashMap<String, Object>()

and subsequently with

ConcurrentHashMap<String, Object> accountMap = 
    (ConcurrentHashMap<String, Object>)allInOne.get(account);
accountMap.put("subAccounts", new ConcurrentHashMap<String, Object>());
ConcurrentHashMap<String, Object> subAccountMap = 
    (ConcurrentHashMap<String, Object>)accountMap.get(subAccount);
subAccountMap.put("subAccountData", new ConcurrentHashMap<String, Object>());

I want to loop through subAccountMap, so I can grab specific values from subAccountData.

I've tried all of the returned Enumerations and Sets from the documentation, but I can't make it work because I'm still too new to Java to figure it out. Please show me how.

(I know what I'm doing is bad practice as many great stackers have shown me here and here, but all I'm trying to do is quickly get a working prototype and will clean up the code once finished)

Community
  • 1
  • 1
  • Please show what you've already tried and what went wrong. It's hard to know how to help you without that information. – Jon Skeet Dec 02 '13 at 08:58
  • @JonSkeet Thank you! It's a real mess right now, so I'll try to clean up what I have and post asap. The one I think I had the most luck with was based off of this answer http://stackoverflow.com/a/3768659/1382306 –  Dec 02 '13 at 08:59

1 Answers1

2

You mean something like this?

ConcurrentMap subAccounts = allInOne.get(account).get("subaccounts");
for (String key : subAccounts.keySet()) {
    Object subAccountObject = subAccounts.get(key);
}
Blub
  • 3,762
  • 1
  • 13
  • 24