【发布时间】:2015-07-12 04:24:38
【问题描述】:
我正在尝试将 ints 放入 Arraylist myList 但 Eclipse 指向错误:
The type of the expression must be an array type but it resolved to ArrayList<Integer>
我尝试将原始类型转换为对象类型,但仍然遇到相同的错误。可以帮帮我吗?
import java.util.*;
public class RemoveDuplicates {
public static void main(String[] args){
int[] myArray = {1,1,2,3,4,5,6,7,8,8,9,9,99};
ArrayList<Integer> myList = new ArrayList();
for(int i = 0; i < myArray.length; i++){
for(int j = 1; j < myArray.length; j++){
if(myArray[i] == myArray[j]){
myList.add(myList[i]);
}
}
}
}
}
【问题讨论】: