手记

java.util.ConcurrentModificationException: null报错

Set<Post> posts = obj_fileFolder.getPosts();
if (posts.size() != 0) {
    Iterator<Post> iterator = posts.iterator();
    while (iterator.hasNext()) {
        if (iterator.next().getId() == data_post.getId()) {
            posts.remove(iterator.next());//出错位置
        }
        obj_fileFolder.setPosts(posts);
        fileFolderService.addFolder(obj_fileFolder);
    }
}
iterator.remove();//改成用迭代器删除

问题解决。

1人推荐
随时随地看视频
慕课网APP