public class Key {
}
public class Value {
}
public class MapExample {
private Map<Key, List<Value>> _map;
public MapExample {
_map = new HashMap<Key, List<Value>>();
}
public void addValue(Key key, Value value) {
List<Value> vs = _map.get(key);
if(vs==null){
vs = new ArrayList<Value>();
vs.add(value);
_map.put(key,vs);
return;
}
vs.add(value);
}
public List<Value> getValues(Key key) {
return _map.get(key);
}
}
No comments:
Post a Comment