这是代码sinplet:
Excel excel = new Excel();
ArrayList<Integer> a1=excel.readExcelSheet("C:\\Users\\Madhukar\\Desktop\\Employee.xls");
System.out.println("Using Iterator");
Iterator iterator = a1.iterator();
while (iterator.hasNext()) {
System.out.println(iterator.next());}
int x=a1.size();
int[] a3=new int[x];
a3=a1.toArray(a3);
这是错误信息:
no suitable method found for toArray(int[]) method AbstractCollection.toArray(T#1[]) is not applicable (inferred type does not conform to upper bound(s) inferred: int upper bound(s): Object)
where T#1,T#2 are type-variable...
最佳答案
原语和泛型不匹配。您需要 Integer[]
而不是 int[]
。
关于java - Arraylist 到 Array 的转换 - toArray() 函数推断类型不符合上限错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26111397/