📅  最后修改于: 2022-03-11 14:52:12.763000             🧑  作者: Mango
public static Set findDuplicates(List listContainingDuplicates) {
final Set setToReturn = new HashSet();
final Set set1 = new HashSet();
for (String yourInt : listContainingDuplicates) {
if (!set1.add(yourInt)) {
setToReturn.add(yourInt);
}
}
return setToReturn;
}