Question: Please write the following program in JAVA. Thanks! Create a class named MyList. It will use a Linked List of integers as its attribute. The

Please write the following program in JAVA. Thanks!

Please write the following program in JAVA. Thanks! Create a class named

Create a class named MyList. It will use a "Linked List of integers as its attribute. The constructor will simply create an empty list. This will be a different type of Linked List, as all of the items will be in ascending numerical order. That means items will not necessarily be placed at the end of the list, but placed where it should be located. Your list should only contain unique items. Therefore if your add) method is passed an integer that already exists on the list, do not add it. The list should contain only one instance of an integer; no duplicate values. Note that the iterator simply uses the next) method, so if you use the iterator to find the location, you may need to keep track of the current index yourself. he following are the methods to create for this class 1. add(value) : Add the specified integer value to its appropriate place on the list 2. remove(value) : Remove the specified value from the list 3. list0 : This method uses the iterator to print the contents of the list. It should appear on the same line, separated by commas. For example: 1, 3, 4, 6, 8 Note that the last item will NOT have a comma following it. 4. maxgap0 : This method will return the largest difference between items on the list. For example, in the sample list displayed in #3 above, the largest gap is 2 (between 4 and 6 and between 6 and 8)

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!