如何使用Java 8迭代和比较两个列表

时间:2019-06-17 16:45:34

标签: java java-8

**I don't have an idea of how to iterate and compare the list using Java 8, can anyone please help for the below code. So that I can reduce the code length and also to avoid code vulnerability**

实际上,我已经尝试通过在Google上按流函数和所有函数搜索它来进行尝试,但是我没有找到合适的解决方案

//下面的代码

for(int i=0;i<previousModerators.size();i++){
int count=0;
for(int j=0;j<newModerators.size();j++){
//we want to itearete the two lists to compare the values
if(previousModerators.get(i).getEmpId().equals(newModerators.get(j).getEmpId()))
{
count++;

}
if(count==0){
removeModeratorList.add(previousModerators.get(i);
//so that we can delete the moderators here
}


}

}

0 个答案:

没有答案