Brand
public class Brand {
private String id;
private String name;
private String parentId;
private List<Brand> children;
}
treeDemo
public class demo {
public static void main(String[] args) {
//1.查询所有集合放在list里面
List<Brand> brands = Arrays.asList(
new Brand("1", "brand1", null),
new Brand("2", "brand2", null),
new Brand("3", "brand3", "1"),
new Brand("4", "brand4", "1"),
new Brand("5", "brand5", "2"),
new Brand("6", "brand6", "2"),
new Brand("7", "brand7", "3")
);
//存储树
HashMap<String, List<Brand>> brandMap =