Java Reference
In-Depth Information
public int compareTo(Person person) {
if( person == this) {
return 0;
}
return this.name.compareTo(person.name);
}
@Override
public String toString() {
return name;
}
protected String name;
}
Directory "TryFlexibleBinaryTree"
The Manager class definition is the following:
public class Manager extends Person {
public Manager(String name, int level) {
super(name);
this.level = level;
}
@Override
public String toString() {
return "Manager " + super.toString() + " level: " + level;
}
protected int level;
}
Directory "TryFlexibleBinaryTree"
You can put the Person and Manager class definitions in the same directory as the following source file,
which stores Manager objects in a BinaryTree<Manager> object:
public class TryFlexibleBinaryTree {
public static void main(String[] args) {
BinaryTree<Manager> people = new BinaryTree<>();
Search WWH ::




Custom Search