如何在每次运行此循环时使用我目前设置的所有元素只映射到映射的方式在此情况下将键[i]增加1为1.我试图找出每个数字出现多少次。我在list.get(i)之后的空点上尝试了+1,但是只是将每个元素映射为1.谢谢。尝试使用Hashmap <Integer,Integer>
List<Integer> list = new ArrayList<Integer>();
HashMap<Integer,Integer> Mode = new HashMap<Integer, Integer>();
for (int i = 0; i < arr.length; i++) {
for (int j = 0; j < arr[i].length; j++) {
list.add(arr[i][j]);
}
}
System.out.println(list);
int count = 1;
for(int i = 0; i < list.size(); i ++) {
Mode.put(list.get(i),);
int count = 1可以忽略! – Kristopher
你的问题不是很理解,但评论是好的 – Kushan
哈哈对不起,从10AM MT时间开始就对这些作业感到抱歉,谢谢你的帮助,我真的很感激它 – Kristopher