title: based on recursion using java
body: <pre><code>public void length() {
      System.out.println(length(head, 0));
  }
  public int length(Node he, int count) {
      if(he!=null) {
          // System.out.println(he.data +"   "+count++);
          // count++;
          // return length(he.next, count);
          return length(he.next, count++);
      }
      return count;
  }
  </code></pre>
  
  <p>In the code above, I have to find the length of linked list. If I run the same code, I am getting the length 0.But, when i use commented code and I am getting the correct length. Why is that happening?</p>