recursion - next cannot be resolved to a value or field in java -


I have this question:

Write a recursive Java function, which is the number of nodes in a circularly Calculates the linked list.

Here is the method / function:

  public int countNodes (node ​​node) {if (node ​​== null) {return 0; } And {return 1 + count node (node ​​number}}   

I get an error in line return 1+ counttodes (node. Nxt); that says: Next Java Can not resolve a value or field in

What should I do to fix this error?

The node class should be like this:

  public class node {next private node; public node getNext (front); } // setter and other stuff}   

and you must call node.getNext ()

  back to 1 + countNodes (node ​​.getNext ()) .;   

Do not forget that Java is an object-oriented language.

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -