1");
Comment comment2 = new Comment(2,-1,"留言2");
Comment comment3 = new Comment(3,1,"留言3,回复留言1");
Comment...comment4 = new Comment(4,1,"留言4,回复留言1");
Comment comment5 = new Comment(5,2,"留言5,回复留言2");
Comment comment6...= new Comment(6,3,"留言6,回复留言3");
//添加非回复评论
for (Comment comment : commentList) {
if (comment.getParentId...非回复评论id匹配到评论的parentId,添加到该评论的children列表中。
递归调用。...结果展示:
github 源码
https://github.com/jeremylai7/java-codes/tree/master/basis/src/main/java/recurve