Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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, Iterable and Iterator interfaces

-The SimpleArrayList class implements the ListADT and Iterable interfaces.

-The SimpleArrayListIterator class implements the Iterator interface.

-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 static  ListADT 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Secrets Of Analytical Leaders Insights From Information Insiders

Authors: Wayne Eckerson

1st Edition

1935504347, 9781935504344

More Books

Students also viewed these Databases questions

Question

Divide: 2 3 4 7

Answered: 1 week ago