-
Notifications
You must be signed in to change notification settings - Fork 111
Expand file tree
/
Copy pathArrayListCombiner.java
More file actions
37 lines (23 loc) · 900 Bytes
/
ArrayListCombiner.java
File metadata and controls
37 lines (23 loc) · 900 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package ArrayListCombiner;
import Employee.Employee;
import java.util.ArrayList;
/**
* Create two generic methods that take two arraylists.
*
* The methods should both append the second ArrayList's items, to the first.
* Use a wildcard for one of the type arguments in each method.
*
* The first method should be called extendCombiner and should use ? extends E
*
* The second method should be called superCombiner and should use ? super E
*/
public class ArrayListCombiner {
//public static void extendCombiner(ArrayList<E> first, ArrayList<E> second)
// ? extends guaranteeing it's passing in correct type
public static <E> void extendCombiner(ArrayList<E> first, ArrayList<? extends E> second) {
first.addAll(second);
}
public static <E> void superCombiner(ArrayList<? super E> first, ArrayList<E> second) {
first.addAll(second);
}
}