Guest User

Untitled

a guest
Jun 18th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. import java.util.Vector;
  2.  
  3. class Item {
  4. public int val;
  5. public Vector<Item> children;
  6. Item(int val) {
  7. this.val = val;
  8. this.children = new Vector<Item>();
  9. }
  10. public Item addChild(int val) {
  11. children.add(new Item(val));
  12. return children.lastElement();
  13. }
  14. }
  15. public class Tree {
  16. public static Item root;
  17. public static void main(String[] args) {
  18. Item curr = root = new Item(0);
  19. curr = curr.addChild(10);
  20. //...
  21. }
  22. }
Add Comment
Please, Sign In to add comment