1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
import java.util.*;
import java.util.function.*;
public class Zip {
public static void main(String[] args) {
List<List<Integer>> result = handle(Arrays.asList(1, 2, 3), Arrays.asList(4, 5, 6), (i, j) -> Arrays.asList(i, j));
System.out.println(result);
}
public static <T, U, R> List<R> handle(List<T> list, List<U> list1, BiFunction<T, U, R> biFunction) {
List<R> result = new ArrayList<>();
for(int i = 0; i < list.size(); i ++) {
result.add(biFunction.apply(list.get(i), list1.get(i)));
}
return result;
}
}
|