1 public static Set<String> findDuplicates(List<String> listContainingDuplicates) {
2
3 final Set<String> setToReturn = new HashSet<String>();
4 final Set<String> set1 = new HashSet<String>();
5
6 for (String yourInt : listContainingDuplicates) {
7 if (!set1.add(yourInt)) {
8 setToReturn.add(yourInt);
9 }
10 }
11 return setToReturn;
12 }