java generics
// generic methods
public List fromArrayToList(T[] a) {
return Arrays.stream(a).collect(Collectors.toList());
}
public static List fromArrayToList(T[] a, Function mapperFunction) {
return Arrays.stream(a)
.map(mapperFunction)
.collect(Collectors.toList());
}
// bounded generics
public List fromArrayToList(T[] a) {
...
}
//multiple bounds
// upper bound wildcards
public static void paintAllBuildings(List extends Building> buildings) {
...
}
// lower bound wildcard
super T>
|