62,621
社区成员
发帖
与我相关
我的任务
分享List t = null;
int[] arr = new int[] {1, 2, 3, 4, 5, 4, 4, 4, 2, 2, 1, 1, 6 };
Map m = new HashMap();
for (int i : arr) {
if (m.containsKey(i)) {
List w = (List) m.get(i);
w.add(i);
} else {
t = new ArrayList();
t.add(i);
m.put(i, t);
}
}
Iterator it = m.entrySet().iterator();
while (it.hasNext()) {
Map.Entry v = (Map.Entry) it.next();
System.out.println(v.getValue());
}