The Node class should be like this:
public class Node {
private Node next;
public Node getNext(){
return next;
}
//setter and other stuff
}
and you have to call node.getNext()
return 1+countNodes(node.getNext());
Don't forget that Java is a object oriented language.