title: next cannot be resolved to a value or field in java
body: <p>I have this question:</p>
  
  <p>Write a recursive java function that counts the number of nodes in a circularly 
  linked list.</p>
  
  <p>Here is the method/function: </p>
  
  <pre><code>public int countNodes(Node node){
  
      if (node == null) {
          return 0;
      }
      else{
              return 1+countNodes(node.next);
      }
  }
  </code></pre>
  
  <p>I get an error in the line 
  return 1+countNodes(node.next); 
  which says that: next cannot be resolved to a value or field in java</p>
  
  <p>What am I supposed to do to fix this error?</p>