📜  java 泛型类型方法 - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:11.587000             🧑  作者: Mango

代码示例1
// 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 buildings) {
        ...
    }
    
// lower bound wildcard