Hi, I am trying to code a program which will allow a user to search through a .db file for a word which is specified through an argument. The main class is in a different file. I am having a hard time putting the contents from the DB file into a binary search tree. "tree.put" is called from the main file. Can someone please tell me why this code isnt working?

// Development version of treemap.
// To be deleted and replaced by an actual implementation that
// does *NOT* use java.util.TreeMap.

import static java.lang.System.*;

class treemap {

  public class tree {
     public String key;
     public String value;
     public  tree left;
    public  tree right;

        public tree(String s){
                 key= s;
                left=null;
                right=null;
        }

   }

   tree root = null;

   java.util.TreeMap <String, String> tree
         = new java.util.TreeMap <String, String> ();


public String get (String key) {
        tree newNode = new tree(key);
        if(key.compareTo(newNode.key)>0){
                System.out.println(">0");
        }
        if(key.compareTo(newNode.key)<0){
                System.out.println("<0");
        }
        else System.out.println("Found");

}
 public String put (String key) {
        tree newNode = new tree(key);
        if(root == null) root = newNode;
        if(root!=null){
                if(key.compareTo(newNode.key)>0){
                        if(newNode.left==null) newNode.left= newNode;
                else left.put(newNode);
                }
                else if(key.compareTo(newNode.key)<0){
                        if(newNode.right == null) newNode.right = newNode;
                        else newNode.right.put(newNode);
                }
   }
}
private void debug_tree_recur (tree node, int depth) {
   }

   public void debug_tree () {
      debug_tree_recur (root, 0);
   }


}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.