Question: //trying to make single linked list that puts input from user to the linkedlist and prints but could not get it to work public class
//trying to make single linked list that puts input from user to the linkedlist and prints but could not get it to work
public class PopQuiz { static class Node { private Node list; private String item; public static Node next; { list= null; while(!StdIn.isEmpty()) { Node old= list; //putting null in old list=new Node(); //making new node and putting it in list list.item= StdIn.readString(); //putting inputs in list.item Node.next= old; //pushing null 1 node to the end } } private static Node t; public static void main(String[] args) { for (Node list= t ; t!= null; t=Node.next) { StdOut.println(t.item); }
} } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
