hi i am trying to implement a sorted tree structure where each treenode element must be Comparable. The problem i am having is in the constructors.
I first have a constructor such that:
I think this is fine and will only allow a treenode to be constructed with an element that must be Comparable However i have another constructor with no parameters (Default Constructor) but i cant make element be of type Comparable when i try:Code:public SortedTreeNode(Comparable element, ArrayList<SortedTreeNode> offspring) {
this.offspring = offspring;
this.element = element;
}
This throws error saying comparable is abstract ? How can i make the check so that when a tree node is constructed it must be of type Comparable??Code:public SortedTreeNode() {
this.offspring = new ArrayList();
this.element = new Comparable();
}
Thanks.
