defining a Tree class


class Tree
{
  private Node root; // a reference to the root of the tree
}

// A node of a tree will have 3 fields: a link to the left child, 
// a link to the right child and an info/item field 


class Node
{

 int item;
 Node lchild, rchild;

 Node (int i, Node l, Node r)
 {
   item = i;
   lchild = l;
   rchild = r;
 }
}


// In-order traversal to print the item using this data structure, 
// first in the Tree class


public void inPrint()
{
   if (root!=null)
     root.inPrint();
}

// then, in the *inner* Node class

void inPrint()
{
  if(lchild != null)
    lchild.inPrint();  // print nonempty left subtree
    System.out.println(item);

  if(rchild != null)
    rchild.inPrint();  // print nonempty right subtree
    System.out.println(item);

}