BAEL-367 - Simplyfing code

This commit is contained in:
slavisa-baeldung
2016-12-05 10:59:53 +01:00
parent aba015e1ad
commit 4f4782255a
2 changed files with 3 additions and 5 deletions
@@ -13,9 +13,8 @@ public class Generics {
}
// definition of a generic method
public static <T, G> List<G> fromArrayToList(T[] a, List<G> list, Function<T, G> mapperFunction) {
List<T> listWithTypeT = Arrays.stream(a).collect(Collectors.toList());
return listWithTypeT.stream().map(mapperFunction).collect(Collectors.toList());
public static <T, G> List<G> fromArrayToList(T[] a, Function<T, G> mapperFunction) {
return Arrays.stream(a).map(mapperFunction).collect(Collectors.toList());
}
// example of a generic method that has Number as an upper bound for T