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
Post a Comment