java组装树状结构数据集合_JAVA构建List集合为树形结构
package com.zving.tree;
import java.util.ArrayList;
import java.util.List;
/**
* 樹形結構實體類
* @author clove
*/
public class Node {
private int id;
private int pid;
private String name;
private String type;
private List children = new ArrayList<>();
public Node(int id, int pid) {
this.id = id;
this.pid = pid;
}
public Node(int id, int pid, String name, String type) {
this(id, pid);
this.name = name;
this.type = type;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getPid() {
return pid;
}
public void setPid(int pid) {
this.pid = pid;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public List getChildren() {
return children;
}
public void setChildren(List children) {
this.children = children;
}
}
總結
以上是生活随笔為你收集整理的java组装树状结构数据集合_JAVA构建List集合为树形结构的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 键盘接口和七段数码管的控制实验
- 下一篇: win10计算机修改底色,win10电脑