Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Vector;
- class Item {
- public int val;
- public Vector<Item> children;
- Item(int val) {
- this.val = val;
- this.children = new Vector<Item>();
- }
- public Item addChild(int val) {
- children.add(new Item(val));
- return children.lastElement();
- }
- }
- public class Tree {
- public static Item root;
- public static void main(String[] args) {
- Item curr = root = new Item(0);
- curr = curr.addChild(10);
- //...
- }
- }
Add Comment
Please, Sign In to add comment