Question: Implement a static generic method named problem3_append that takes as a parameter two generic array lists (a and b), and appends the elements of b

Implement a static generic method named problem3_append that takes as a parameter two generic array lists (a and b), and appends the elements of b to a (returning void). The elements in b must be either the same type as the elements of a, or else a subtype of the elements of a. For example, if people is an ArrayList and students is an ArrayList (and Student is a sub-class of Person), then append(people, students) should compile, but append(students, people) should not.

Example: ArrayList a = new ArrayList<>();

ArrayList b = new ArrayList<>();

a.add(new Person("Fred"));

a.add(new Person("Sally"));

b.add(new Student("Bob", "Bioinformatics"));

b.add(new Student("Rubia", "Computer Science"));

problem3_append(a, b);

// a now contains Fred, Sally, Bob, Rubia

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!