list获取重复的数据
static void toolDuplicateReview(List<mdoel> list,StringBuilder stringBuilder){
//创建set去重的email集合
Set setEmail = new HashSet();
//创建set去重的mobile集合
Set setMobile = new HashSet<>();
//循环遍历进行去重查询
for (int i = 0; i < list.size(); i++) {
// 若邮箱和手机有一个重复则进入 这儿是根据两个属性进行重复逻辑
if(setEmail.contains(list.get(i).getEmail()) || setMobile.contains(list.get(i).getMobile())){
// 精准去定位是当前行的 邮箱重复还是手机重复
if(setEmail.contains(list.get(i).getEmail())){
stringBuilder.append("第"+(i+1)+"行,邮箱:"+list.get(i).getEmail()+" 出现重复!\n");
}
if(setMobile.contains(list.get(i).getMobile())){
stringBuilder.append("第"+(i+1)+"行,手机:"+list.get(i).getMobile()+" 出现重复!\n");
}
}
// set起来list后面的数据继续进行比较
//set邮箱
setEmail.add(list.get(i).getEmail());
//set手机
setMobile.add(list.get(i).getMobile());
}
}