我在地图内的地图内有地图。格式是HashMap<String, Map>
采样数据:如何在地图内的地图内迭代地图
deviceName={commandName={dataKey1=[dataValue1], dataKey2=[dataValue2]}}
它的设置是deviceName
是key
和commandName
是它的价值的方式。为了简单起见,现在只有一个,但可能有多个命令。在第二次迭代commandName
是key
和{dataKey1=[dataValue1], dataKey2=[dataValue2]}
是值。在第三次迭代中,是关键字,dataValue1
是值(它是一个arrayList)。
我可以遍历一个,但我不知道如何做到这一点。
public void analyseVersion(Map cmd) {
Iterator deviceIT = cmd.keySet().iterator();
while (deviceIT.hasNext()) {
String deviceName = (String) deviceIT.next();
//Map<String, Map> cmd = (Map<String, Map>) cmd.get(deviceName);//This will not work.
//At this point I want to iterate through each command and for each command iterate through each data set.
}
}
你为什么不使用泛型的声明? –