int all[]=new int[]{1,2,1,2,1,3,4,5,2,7}; Arrays.sort(all); System.out.println(Arrays.toString(all)); HashSet set=new HashSet (); for(Integer a:all) { set.add(a); } System.out.println(set); int[] input = {2,3,6,6,8,9,10,10,10,12,12}; ArrayList list = new ArrayList (); for(int i = 0 ; i < input.length; i++) { if(!list.contains(input[i])) { System.out.println(input[i]); list.add(input[i]); } } System.out.println(list); private void removeTheDuplicates(List myList) { for(ListIterator iterator = myList.listIterator(); iterator.hasNext();) { Customer customer = iterator.next(); if(Collections.frequency(myList, customer) > 1) { iterator.remove(); } } System.out.println(myList.toString()); } Set s = new HashSet (listCustomer); If you need to preserve elements order then use LinkedHashSet instead of HashSet ...