public class Solution {
public static void main(String[] args) {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int l1=Integer.parseInt(br.readLine());int count=0;
String l2=br.readLine();
String[] a=l2.split(" ");int[] no=new int[l1];
for (int i=0;i<l1;i++) {
no[i]=Integer.parseInt(a[i]);
}
List list=Arrays.asList(no);
Set<Integer> set=new LinkedHashSet<Integer>(list);
***for (int integer : set) {***
count=Math.max(count, Collections.frequency(list, integer));
}
}
}
我在代碼的突出部分得到了java.lang.ClassCastException: [I cannot be cast to java.lang.Integer at Solution.main(Solution.java:23)
。這是什麼原因?java.lang.ClassCastException:[我不能轉換爲java.lang.Integer
數組的[Arrays.asList()可能的重複](http://stackoverflow.com/questions/1248763/arrays-aslist-of-an-array) –