我有一个Multimap,它在" place“和" event”的键值下多次保存自定义对象(地点和事件),在这些对象中,我有地点名称和事件名称(getters)。如何在遍历Multimap时访问这些值。
发布于 2014-07-21 20:03:04
你能做到的,
Collection<Object> values = map.get(key);
checkState(values.size() == 2, String.format("Found %d values for key %s", values.size(), key));
return values.iterator().next(); // to get the first
Iterator<Object> it = values.iterator();
it.next(); // move the pointer to the second object
return it.next(); // get the second objecthttps://stackoverflow.com/questions/24864348
复制相似问题