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();//改成用迭代器删除
问题解决。