Question: java i have the code: import java.util.Random;//to generate random numbers /ode class class node{ int value; node next; node(int v) { value=v; next=null; } }
java
i have the code:
import java.util.Random;//to generate random numbers /ode class class node{ int value; node next; node(int v) { value=v; next=null; } }
public class Main { public static void main(String[] args) { //declaring array with size, where each index is pointed to a node with value 0 node n[] = new node[3]; n[0] = new node(0); n[1] = new node(0); n[2] = new node(0); Random R = new Random(); /ow adding a random integer at the end of the array, at each index for(int i=0;i\t"+n[i].next.value); } } } output:

but I want multiple random integers in the random integer column, for example, say I want 37 random integers to populate the array of size 3 so every time a random integer is generated a new node is created and it is added to the list using a loop (it's okay if the length of the list is different at each index as long as there are 37 random integers)
How would this be implemented?
HeaderNode Index O 1 2 0 0 0 0 Random Integer 1480876087 61964907 404004622 - - Program finished with exit code 0 Press ENTER to exit console
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
