当在方法中创建时,我可以nestedMap
在我的迭代器中访问我的,如下所示:nestedMap
put()
@Override
public String put(final String row, final String column, final String value) {
/**
* Second map which is contained by centralMap, that contain Strings as
* Keys and Values.
*/
Map<String, String> nestedMap;
if (centralMap.containsKey(row))
nestedMap = centralMap.get(row);
else
nestedMap = new HashMap<String, String>();
if (!nestedMap.containsKey(column))
counter++;
centralMap.put(row, nestedMap);
return nestedMap.put(column, value);
}
并且 centralMap 被声明为一个对象变量,
private final Map<String, Map<String, String>> centralMap;
但仅在构造函数中实例化,如下所示:
centralMap = new HashMap<String, Map<String, String>>();
我试图实现的方法是 remove 方法:
@Override
public void remove() {
for (Map<String, String> map : centralMap.values()) {
map = centralMap.get(keyName);
iteratorNested.remove();
if (map.size() <= 0)
iteratorCentral.remove();
}
}
非常感谢!