Question
Java Programming: -The ListADT , Iterable and Iterator interfaces -The SimpleArrayList class implements the ListADT and Iterable interfaces. -The SimpleArrayListIterator class implements the Iterator interface.
Java Programming:
-The ListADT
-The SimpleArrayList
-The SimpleArrayListIterator
-The items can be compared with the equals method.
-null and duplicate items are not in ListADT instances.
-The NullListException class is implemented as an unchecked exception with a zero-argument constructor.
Complete the Java generic method specified below, which is part of some main class. To receive full credit, your solution:
May use the add and remove List ADT methods.
May not use either the get or contains List ADT methods.
Must explicitly use iterators for traversing lists. May not use for-each loops.
May not use the remove Iterator method.
Must not change the contents of any of the parameters.
Must produce the resulting list in the order shown in the examples below.
public staticListADT intersection( ListADT list1, ListADT list2 ) { // If list1 or list2 (or both) is null, throw a NullListException. // If list1 or list2 (or both) is empty, return a new empty list. // Otherwise return a new list that contains the objects that are in both list1 and list2. // For example: // list1: A,B,C list2: X,Y,Z result: empty // list1: A,B,C,D list2: Z,D,Y,B,X result: B,D // list1: A,B,C list2: A,B,C,Z result: A,B,C // list1: A,B,C,X list2: C,B,A result: A,B,C
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