1 /**
2 This class demonstrates the advanced techniques in BinarySearchTree2.
3 */
4 public class TreeTester2
5 {
6 public static void main(String[] args)
7 {
8 BinarySearchTree2<Student> students = new BinarySearchTree2<Student>();
9 // Can form BinarySearchTree2<Student> even though Student
10 // implements Comparable<Person> and not Comparable<Student>
11
12 students.add(new Student("Romeo", "Art History"));
13 students.add(new Student("Juliet", "CS"));
14 students.add(new Student("Tom", "Leisure Studies"));
15 students.add(new Student("Diana", "EE"));
16 students.add(new Student("Harry", "Biology"));
17
18 class PrintVisitor implements Visitor<Object>
19 {
20 public void visit(Object data)
21 {
22 System.out.println(data);
23 }
24 }
25
26 // Can pass a Visitor<Object>, not just a Visitor<Student>
27 students.inorder(new PrintVisitor());
28 }
29 }