Question: Add an instance variable currentSize to our implementation of the LinkedList class. Modify the add, addLast, and remove methods of both the linked list and
Add an instance variable currentSize to our implementation of the LinkedList class.
Modify the add, addLast, and remove methods of both the linked list and the list iterator to update the currentSize variable so that it always contains the correct size. Change the size method of Exercise • E16.4 so that it simply returns the value of currentSize.
Data from exercise E16.4
Add a method size to our implementation of the LinkedList class that computes the number of elements in the list by following links and counting the elements until the end of the list is reached.
Step by Step Solution
3.36 Rating (162 Votes )
There are 3 Steps involved in it
To add and update an instance variable currentSize in your implementation of javautilLinkedList we f... View full answer
Get step-by-step solutions from verified subject matter experts
