package generischer_binaerbaum; public class BinaryTree> { private Node root; public boolean contains(T element) { if (root == null) return false; return root.contains(element); } public void append(T element) { if (root == null) { root = new Leaf<>(element); } else { root = root.append(element); } } public boolean equals(Object o) { if (!(o instanceof BinaryTree)) return false; BinaryTree casted = (BinaryTree) o; if (this.root == null) { if (casted.root != null) return false; else return true; } else { return root.equals(casted.root); } } public String toString() { if (root == null) return ""; return root.toString(); } public static void main(String[] args) { BinaryTree bt = new BinaryTree<>(); bt.append(new Integer(8)); bt.append(new Integer(2)); bt.append(new Integer(4)); bt.append(new Integer(1)); bt.append(new Integer(0)); bt.append(new Integer(7)); System.out.println(bt.contains(new Integer(8))); System.out.println(bt); } }