1 HashSet<Integer> hashSet = new HashSet<Integer>(); 2 for (int i = resultDoctorDetails.size() - 1; i >= 0; --i) { 3 ResultDoctorDetail temp = resultDoctorDetails.get(i); 4 if (!hashSet.contains(temp.getUserId())) { 5 hashSet.add(temp.getUserId()); 6 } else { 7 resultDoctorDetails.remove(i); 8 } 9 }