class Node { char label; T value; Node children[]; Node(char label) { this.label = label; this.value = null; this.children = new Node[1< cur = this; for(char c: str.toCharArray()) { if(cur.children[c] == null) cur.children[c] = new Node(c); cur = cur.children[c]; } cur.value = value; } T get(String str) { Node cur = this; for(char c: str.toCharArray()) { if(cur.children[c] == null) return null; cur = cur.children[c]; } return cur.value; } void enumerate(String prefix) { prefix += label; if(value != null) System.out.println(prefix + " => " + value); for(int i=0; i root = new Node((char)0); root.set("plop", "coucou"); root.set("plip", "recoucou"); root.set("abc", "zzz"); root.set("abd", "kkk"); System.out.println(root.get("plop")); root.enumerate(""); } }