top of page

package alıştırmalar;

 

import java.util.ArrayList;

import java.util.Scanner;

 

public class exercise11_13 {

 

public static void main(String[] args) {

// TODO Auto-generated method stub

Scanner input = new Scanner(System.in);

ArrayList<Integer> mylist = new ArrayList<>();

System.out.println("10 adet sayı giriniz :");

int sayı;

for (int i = 0; i < 10; i++) {

sayı = input.nextInt();

mylist.add(sayı);

}

System.out.println("------------İlk Listemiz-----------\n" + mylist);

removeDuplicates(mylist);

 

}

 

public static void removeDuplicates(ArrayList<Integer> list) {

ArrayList<Integer> newlist = new ArrayList<>();

int i = 0;

do {

if (!newlist.contains(list.get(i)))

newlist.add(list.get(i));

i++;

} while (i < 10);

System.out

.println("------------------------------------\nDistnict numbers :"

+ newlist);

}

}

 

bottom of page