67,515
社区成员
发帖
与我相关
我的任务
分享
for (int i = 0; i < perlist.size(); i++) {
Object[] object = (Object[]) perlist.get(i);
System.out.println("Get: " + object[0]);
if (map.containsKey(object[0])) {
((List<Object>) map.get(object[0])).add(object);
} else {
System.out.println("NewKey: " + object[0]);
maplist=new ArrayList<Object>();
maplist.add(object);
map.put((String)object[0], maplist);
}
}
System.out.println("MapSize: " + maplist.size());
for (int i = 0; i < perlist.size(); i++) {
Object[] object = (Object[]) perlist.get(i);
if (map.containsKey(object[0])) {
((List<Object>) map.get(object[0])).add(object);
} else {
maplist=new ArrayList<Object>();
maplist.add(object);
map.put((String)object[0], maplist);
}
}
HashMap map = ...;
Object key =...;
Object value = ...;
Object o = map.put(key, value);
if (o != null)
{
throw new Exception("键值重复"+key);
}