作业
public interface TreeInt {
public void addTree(TreeInt treeInt);
public void print();
}
public class TreeNode implements TreeInt {
private List<TreeInt> treeInts = new ArrayList<>();
public void addTree(TreeInt ){
this.treeInts.add(treeInt);
}
public void print(){
treeInts.parallelStream().forEach((x) -> x.print());
}
}
public class TreeSub implements TreeInt {
private String value;
private TreeInt treeInt;
public void addTree(TreeInt ){
this.treeInt = treeInt;
}
public void print(){
System.out.println(value);
treeInt.print();
}
}
评论