-
Notifications
You must be signed in to change notification settings - Fork 111
Expand file tree
/
Copy pathArrayListCombiner.java
More file actions
31 lines (22 loc) · 905 Bytes
/
ArrayListCombiner.java
File metadata and controls
31 lines (22 loc) · 905 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
package ArrayListCombiner;
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<E> {
// private ArrayList<E> first;
// private ArrayList<E> second;
public ArrayListCombiner() {
// first = new ArrayList<>();
// second = new ArrayList<>();
}
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);
}
}