The node class in linked lists specifically the constructor and using it to create a linked list of random integers
12:00 17 Nov 2018

My Node Constructor looks like this:

 public Node(int ndata, Node nlink)
         {
             this.data=ndata; 
             this.link = nlink; 
         }

This constructor takes two parameters, the data for the Node and the link to the next node. For everything I have seen that makes linked lists, however, a new node is created like this:

Node nextNode = new Node (data);

I can't run the program if I don't put the second parameter into the program for some reason, however. This is the code I have.

public static Node ListGenerator()
{
    // Generate RANDOM List
    int j, cint, size;
    Scanner input = new Scanner(System.in); 
    System.out.println("Please enter the size"); 
    size = input.nextInt(); 
    //Node head; 
    Node current = null; 
    for (j = 1; j <= size; j++) {

        cint = (int)((Math.random() * 100)+1); 
        Node nextNode = new Node (cint,current.getLink()); 
        current = nextNode; 

    } return current;     

    // ...  
}

I am new to linked lists so this is very confusing to me even if it is probably a very simple thing I am not getting.

java linked-list nodes computer-science