Question: IN JAVA!!!!!! Code Is From Here...Must Write Code First and then Implement it in the prompt above OurLinkedList2.java: class ListItem { String data; ListItem next;

IN JAVA!!!!!!IN JAVA!!!!!! Code Is From Here...Must Write Code First and then Implement

Code Is From Here...Must Write Code First and then Implement it in the prompt above

it in the prompt above OurLinkedList2.java: class ListItem { String data; ListItem

OurLinkedList2.java:

class ListItem { String data; ListItem next; } public class OurLinkedList2 { ListItem front = null; ListItem rear = null; int numItems = 0; public void add (String s) { if (front == null) { front = new ListItem (); front.data = s; rear = front; rear.next = null; } else { ListItem nextOne = new ListItem (); nextOne.data = s; rear.next = nextOne; rear = nextOne; } numItems ++; } public int size () { return numItems; } public String get (int i) { if (i >= numItems) { return null; } // Otherwise, count up to the i-th item. int count = 0; ListItem listPtr = front; while (count  

OurLinkedListExample2.java:

public class OurLinkedListExample2 { public static void main (String[] argv) { OurLinkedList2 favoriteShows = new OurLinkedList2(); favoriteShows.add ("Yes minister"); favoriteShows.add ("Seinfeld"); favoriteShows.add ("Cheers"); favoriteShows.add ("Frasier"); favoriteShows.add ("Simpsons"); System.out.println ("List: " + favoriteShows); favoriteShows.printWithAddresses(); favoriteShows.delete ("Frasier"); System.out.println ("After delete: "); favoriteShows.printWithAddresses(); favoriteShows.delete ("Cosby"); System.out.println ("After delete: "); favoriteShows.printWithAddresses(); } }
In-Class Exercise 14: Implement your code in OurLinkedList2.java and test it with OurLinkedListExample2 java

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!