List<BipDetection> bipDetections = bipDetectionDao.getInterfaceAuthorization(A, B);
if (bipDetections!=null&&!bipDetections.isEmpty()) {
BipDetection bipDetectionTemp = new BipDetection();
for (BipDetection bipDetection : bipDetections) {
if ("GETXXXX".equals(bipDetection.getAction())) {
bipDetectionTemp = bipDetection;
// bipDetections.remove(bipDetection);//直接移除
continue;
}
}
bipDetections.remove(bipDetectionTemp);//移除GETXXXX
}
return bipDetections;
移除集合中某一个特定元素的时,我们常用的的方式是:list.remove(); 在这里有一个注意的点,list.remove(); 时,list的size() -1,如果在移除元素的同时还执行 list 其他操作 ,比如赋值。这时候 list的最后一个元素的状态没有改变。