title: Moving method to another class in Java
body: <p>I have two classes: ID3 and Node as shown below:</p>
  
  <pre><code>class Node {
      public Vector kept;
      public Node[] children;
      public Node parent;
  
      public Node() {
          kept = new Vector();
      }
  }
  </code></pre>
  
  <p>and in the other class (<code>ID3</code>) I have a method:</p>
  
  <pre><code>public void sTree(Node node, int heuristic) {
      int noOfIn = noOfAttributes - 1;
  }
  </code></pre>
  
  <p>and I wish to move the <code>sTree()</code> method to the other class (<code>Node</code>), since it is related to the tree. However, the variable noOfAttributes, etc are defined in the ID3 class (global) and so aren't found in the Node class if I move this method (I need them in the ID3 class due to other methods so I can't remove them from ID3 and put them to Node class). How can I solve this problem?</p>