title: traversal method with a return value
body: <p>for trees, in traversal methods I want the values to be returned. the  method i tried only returns one value. </p>
  
  <pre><code> int inorder(BSTNode r) {
     int result = 0 ;
      if (r != null) {
          inorder(r.getLeft());
       result= r.getData();
          inorder(r.getRight());  
      }
     return result;
  }
  </code></pre>
  
  <p>this code works perfectly but I want the method to return the values instead </p>
  
  <pre><code>private void inorder(BSTNode r) {
      if (r != null) {
          inorder(r.getLeft());
          System.out.print(r.getData() + " ");
          inorder(r.getRight());
      }
  }
  </code></pre>