Abstract method[???]

Hello there,
I have a problem with the code im compiling it and it returns an error :
"BinarySearchTree is not abstact and does not override abstract method findNums(int, int , T) in Tree"
Can anyone tell me why's that happening ???
Thanks in advance !

code:

public class BinarySearchTree<T extends Comparable<T>> implements Tree<T>{

    private Node<T> rootNode;
   
    public int min;
    public int max;
   
    public boolean isEmpty(){
        return rootNode == null;
    }
 
    public void insert(T item){
        if (rootNode == null){
            rootNode = new Node<T>(item, null, null);
        }else{
            insertNode(item, rootNode);
        }
    }
   
    //Return all the between numbers of min & max
    public  T findNums(int min, int max, Node rootNode)
    {
        if (rootNode == null)
        {
            return null;
        }
        if (rootNode.data >= min)
        {
            this.findNums(min, max, root.leftNode);
            if (root.data <= max)
            {
                System.out.println(root.data);
            }
        }
        if (root.data <= max)
        {
           this.findNums(min, max, root.rightNode);
        }
    }
 
    //Minimum node
    public T minimum(){
        if (rootNode != null){
            return findMinimumNode(rootNode).getElement();
        }else{
            return null;
        }
    }
    private Node<T> findMinimumNode(Node<T> node){
        if (node.getLeftNode() == null){
            return node;
        }else{
            return findMinimumNode(node.getLeftNode());
        }
    }
   
    private Node<T> insertNode(T item, Node<T> node){
        if (node == null){
            node = new Node<E>(item, null, null);
        }else if (item.compareTo(node.getElement()) < 0){
            node.setLeftNode(insertNode(item, node.getLeftNode()));
        }else if (item.compareTo(node.getElement()) > 0){
            node.setRightNode(insertNode(item, node.getRightNode()));
        }else{
            ;
        }
        return node;
    }
   
    private static class Node<T extends Comparable<T>>{
        private T element;
        private Node<T> leftNode;
        private Node<T> rightNode;
       
        Node(T element, Node<T>leftNode, Node<T>rightNode){
            this.element = element;
            this.leftNode = leftNode;
            this.rightNode = rightNode;
        }
       
        void setLeftNode(Node<T> leftNode){
            this.leftNode = leftNode;
        }
       
        Node<T> getLeftNode(){
            return leftNode;
        }
       
        void setRightNode(Node<T> rightNode){
            this.rightNode = rightNode;
        }
       
        Node<T> getRightNode(){
            return rightNode;
        }
       
        T getElement(){
            return element;
        }
       
        void setElement(T element){
            this.element = element;
        }
     
    }
}

perdoname_Asked:
Who is Participating?
 
Bob LearnedConnect With a Mentor Commented:
I believe that it is because you are not overriding a virtual member:

    public override T findNums(int min, int max, Node rootNode)

Bob
0
 
krakatoaCommented:
Comparable is an interface not a class, so it has to be implemented not extended.

For abstract classes, you need to render method bodies in your subclass.
0
 
Ajay-SinghConnect With a Mentor Commented:
> Comparable is an interface not a class, so it has to be implemented not
extended.
 
 
The class is not extending Comparable
0
 
perdoname_Author Commented:
then what is wrong ??
:S:SS:SS
0
 
Ajay-SinghCommented:
> then what is wrong ??

See the comment of TheLearnedOne http://#20836564
0
All Courses

From novice to tech pro — start learning today.