Hey everyone. As always I'm sorry for my noobness when it comes to java, but I got a question I can't seem to find answered anywhere else on the web. I'm trying to make a simple program that takes whatever number the user types in, and makes a linked linked with the # of random numbers that the user typed. So if the user types 5: you could get
100
26
89
23
54
import java.util.*;
import java.io.IOException;
import java.util.Scanner;
public class LinkedListProgram
{
public static void main(String[] args) throws IOException
{
int i,number;
Scanner sc = new Scanner(System.in);
LinkedList<String> list = new LinkedList<String>();
ListIterator li;
String line;
System.out.println("Enter # of nodes");
number = sc.nextInt();
if (number > 0)
{
while (i = 0; i <= number; i++)
}
else
{
System.out.println("\nnumber is less than 0\n");
}
}
}
I'm not sure how you place numbers into a linkedlist though. I got the while statement down, but idk what to put in it that will make the linked list work as I specified. Any help or tips are greatly appreciated.