/ Published in: Java
This is a java class to generate a tree by given string content
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
import java.util.ArrayList; import java.util.List; /** * To generate a tree by given string content * @author MD. MUZAHIDUL ISLAM ([email protected]) * */ TreeNode parentNode; List<TreeNode> childNodes = new ArrayList<TreeNode>(); int depth = 0; int level = 0; String options; public static List<TreeNode> leafs; this.parentNode = parentNode; this.content = content; this.trace =trace; this.level = level; this.depth = depth; this.options = options; if (level < depth) { createChild(options); } else { leafs.add(this); } } if(isRoot){ leafs = new ArrayList<TreeNode>(); } this.parentNode = parentNode; this.content = content; this.trace =trace; this.level = level; this.depth = depth; this.options = options; if (level < depth) { createChild(options); } else { leafs.add(this); } } for(char c : options.toCharArray()){ } } }