利用 HashSet 去过滤元素是否重复

 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         }
原文地址:https://www.cnblogs.com/xjbBill/p/5884200.html