1.使用了list.remove(obj),没有效果;
2.使用了removeAll也不起作用:
List<User> userRemove = new ArrayList<User>();
//找出要删除的用户
for (User result : list)
{
if (result.getId() == 1 || result.getId() == 3)
{
userRemove.add(result);
}
}
list.removeAll(userRemove);
3.最后使用Iteator实现将指定对象从集合中移除出去:
Iterator<User> it =list.iterator();
while (it.hasNext())
{
User userObj = it.next();
if (StringUtils.isBlank(userObj.getProjects()))
{
it.remove();
}
}