HashMap<String, Map<Integer, Integer>> outer = new HashMap<>();
String abc = //someString;
maxNumber = //somevalue;
minNumber = //somevalue;
Map<Integer,Integer> inner = new HashMap<>();
inner.put(minNumber, maxNumber);
outer.put(abc, inner);
有类似下面的代码。我正从内部地图中检索更多的数字,尝试但无法获取。
for (Map.Entry<String, Map<Integer, Integer>> outer1 : outer.entrySet()) {
System.out.println("Feature: " + outer1.getKey() + "\n");
for (Map.Entry<Integer, Integer> entry : outer1.getValue().entrySet()) {
//.... stuck here.
}
如何从内部地图中获得更大的价值?
答案 0 :(得分:0)
minNumber
是内部地图的关键。因此值为maxNumber
。
for (Map.Entry<String, Map<Integer, Integer>> outer1 : outer.entrySet()) {
System.out.println("Feature: " + outer1.getKey() + "\n");
for (Map.Entry<Integer, Integer> entry : outer1.getValue().entrySet()) {
Integer key = entry.getKey(); // == minNumber
Integer value = entry.getValue(); // == maxNumber
}