Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

// 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DATABASE Administrator Make A Difference

Authors: Mohciine Elmourabit

1st Edition

B0CGM7XG75, 978-1722657802

More Books

Students also viewed these Databases questions

Question

In an Excel Pivot Table, how is a Fact/Measure Column repeated?

Answered: 1 week ago