Question: Project : Implement a circularly linked list In a circular linked list, the tail node points to the head node. Implement MyLinkedList class ( Chapter
Project : Implement a circularly linked list
In a circular linked list, the tail node points to the head node. Implement MyLinkedList class Chapter using a circular linked list. Identify the methods you need to modify and make appropriate changes. Test your new class using the following program.
public class MyCircularLinkedList
public static void mainString args
Create a list
MyList list new MyLinkedList;
Add elements to the list
list.addAmerica; Add it to the list
System.out.println list;
list.add "Canada"; Add it to the beginning of the list
System.out.println list;
list.addRussia; Add it to the end of the list
System.out.println list;
list.addFrance; Add it to the end of the list
System.out.println list;
list.add "Germany"; Add it to the list at index
System.out.println list;
list.add "Norway"; Add it to the list at index
System.out.println list;
Remove elements from the list
list.removeCanada; Same as list.remove in this case
System.out.println list;
list.remove; Remove the element at index
System.out.println list;
list.removelistsize; Remove the last element
System.out.print list
;
for String s: list
System.out.printstoUpperCase;
System.out.print
;
list.forEache System.out.printetoLowerCase;
System.out.print
;
list.streamsortedforEache System.out.printe ;
list.clear;
System.out.println
The list size is list.size;
class MyLinkedList implements MyList
Your implementation
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
