Question: // trying to write code in Java which takes String input from user and puts it in linkedlist as long as user's input is NOT

// trying to write code in Java which takes String input from user and puts it in linkedlist as long as user's input is NOT empty string //Unfortunately my program is not asking for input nor printing the linked list after input is taken // Also confused about usage of .readString(); Explanations appreciated:

public class PopQuiz { static class Node { public boolean isEmpty() { return list.item==null;} 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!