for(Iterator<IAddress> it=addSet.iterator();it.hasNext();){
IAddress address = it.next();
if(address.getId() != null){
Boolean flag = false;
for(IAddress addr : set){
if(addr.getId().equals(address.getId())){
flag = true;
break;
}
}
if(!flag){
it.remove();
}
}
}
List遍历的时候不能直接 remove,实现办法是用 iterator.remove,否则会报ConcurrentModificationException
注意set 在remove操作时set集合不能再有任何修改,否则hashcode发生改变,则不能remove成功
例如以下case
Hibernate.initialize(subAccount.getAuthorizors());
if(subAccount.getAuthorizors() != null){
Iterator<IAuthorizor> iterator = subAccount.getAuthorizors().iterator();
while(iterator.hasNext()){
IAuthorizor authorizor = iterator.next();
if(auth