Question: Define the following methods in MyList and implement them in MyAbstractList: Write a test program that creates two MyArrayLists, list1 and list2, with the initial
Define the following methods in MyList and implement them in MyAbstractList:
Write a test program that creates two MyArrayLists, list1 and list2, with the initial values {"Tom", "George", "Peter", "Jean", "Jane"} and {"Tom", "George", "Michael", "Michelle", "Daniel"}, then perform the following operations:??Invokes?list1.addAll(list2), and displays?list1?and?list2.? Recreates list1 and list2 with the same initial values, invokes list1.removeAll(list2), and displays list1 and list2.? Recreates list1 and list2 with the same initial values, invokes list1.retainAll(list2), and displays list1 and list2.
/** Adds the elements in otherList to this list. * Returns true if this list changed as a result of the call */ public boolean addAl1 (MyList otherList); /** Removes all the elements in otherList from this list * Returns true if this list changed as a result of the call */ public boolean removeAll (MyList otherList); /** Retains the elements in this list that are also in otherList * Returns true if this list changed as a result of the call */ public boolean retainAll1 (MyList otherList);
Step by Step Solution
3.34 Rating (157 Votes )
There are 3 Steps involved in it
Program Plan Define an interface called MyList Add three additional method definitions addAllremove All retatinAll Define an abstract class called MyAbstractList Add three additional method definition... View full answer
Get step-by-step solutions from verified subject matter experts
