public static void main(String args[]) {
int[] array = {4,2,4,6,1,2,4,7,8};
QuChongFu(array);
}
private static void QuChongFu(int[] array){
List list = new ArrayList();
// 循环判断list中是否含有array[i],不含有则在list中添加
for(int i=0;i<array.length;i++){
if(!list.contains(array[i]))
{
list.add(array[i]);
}
}
// 打印结果检验
System.out.println(list);
} |
|