Question
Include an add(E) method in your ListIterator interface. It should add a value to the List just prior to the implicit cursor. (See the API
Include an add(E) method in your ListIterator interface. It should add a value to the List just prior to the implicit cursor. (See the API in the java.util package)
/** Insert the given value just prior to the implicit cursor position. A subsequent call to previous()
should return the inserted value, and a subsequent call to next() should be unaffected.
*/
public void add (E value);
Implement the add(E) method in your ArrayListIterator and RefListIterator classes. Test your solution using DriverLabListIterator.
======================================
ArrayListIterator.java
package list;
public class ArrayListIterator
private boolean forward = true; ArrayListIterator(List
===============================
RefListIterator.java
package list;
public class RefListIterator
private boolean forward = true; RefListIterator(LinkedList =================================================== Driver package listDriver; import java.util.ListIterator; import list.*; /** * Test Iterators and ListIterators. * * @author (sdb) * @version (2020) */ public class DriverLabListIterator { public static void main(String [] args) { List System.out.println ("Testing ListIterators for ArrayLists"); testListIterators (new ArrayList private static void testIterators (List } ============ ListIterator.java package list; public interface ListIterator public E previous(); public void add(E value); } =============================== Iterator.java package list; public interface Iterator }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started