Iterator<Entity> iterator = list.iterator();
while (iterator.hasNext()) {
Entity objects = iterator.next();
Integer answer1= Integer.valueOf(objects.getParentCodeNo());
String answer2= objects.getCodeName();
//和查询条件不一样的过滤掉 其中StringUtils.isNotBlank判断String不为空and不为null
if ((this.query1 != null && !query1.equals(answer1))
|| (StringUtils.isNotBlank(this.query2) && !answer2.contains(this.query2))) {
iterator.remove();
}
}
JAVA 查询条件和iterator
![](https://img-home.csdnimg.cn/images/20240711042549.png)