写一个方法,能够删除ArrayList中的重复数字,其中数字的类型是Integer。要求在原ArrayList中直接删除重复数字。方法原型如下:
public static void removeDuplicate(ArrayList<Integer> list)
在main方法中调用上述方法,输出删除后的结果。例如某次运行结果如下:
输入:34 5 3 5 6 4 33 2 2 4
输出:34 5 3 6 4 33 2
import java.util.ArrayList;
import java.util.Scanner;
public class DeleteProject {
public static void main(String[] args) {
ArrayList<Integer> list =new ArrayList<Integer>();
Scanner input = new Scanner(System.in);
int n=input.nextInt(); //输入要输入的数字个数
for(int i=0;i<n;i++){
list.add(input.nextInt());
}
removeDuplicate(list);
}
public static void