title: Java : How do I implement a generic Binary Search Tree?
body: <p>Until now, I have been writing a Node class as  </p>
  
  <pre><code>class Node {
          private  value;
          private Node left;
          private Node right;
  
          public int getValue() {
              return value;
          }
  
          public void setValue(int value) {
              this.value = value;
          }
  
          public Node getLeft() {
              return left;
          }
  
          public void setLeft(Node left) {
              this.left = left;
          }
  
          public Node getRight() {
              return right;
          }
  
          public void setRight(Node right) {
              this.right = right;
          }
      } 
  </code></pre>
  
  <p>and Binary Search Tree as  </p>
  
  <pre><code>public class BinarySearchTree {
      private Node root;
  
      public BinarySearchTree(int value) {
          root = new Node(value);
      }
  
      public void insert(int value) {
        Node node = new Node(value);
          // insert logic goes here to search and insert
      }
  }
  </code></pre>
  
  <p>Now I would like to support BinarySearchTree to have insert node of any type like strings, people  </p>
  
  <p>How can I make it generic to hold any type?</p>