我想要做的是,将索引存储在当前元素重复的数组列表中,我已经完成了,现在我想检查一下。
HashMap<Integer,ArrayList<Integer>> hmap = new HashMap<>();
for(int i=0;i<arr.length;i++)
{
if(!hmap.containsKey(arr[i]))
{
ArrayList<Integer> a1 = new ArrayList<>();
hmap.put(arr[i],a1);
}
else
hmap.get(arr[i]).add(i);
}
for(Map.Entry m:hmap.entrySet())
{
ArrayList<Integer> alist = {Here it is showing erorr.}m.getValue();
System.out.println(m.getKey()+" ");
for(int i=0;i<alist.size();i++)
System.out.print(alist.get(i)+" ");
}
Run Code Online (Sandbox Code Playgroud)