📅  最后修改于: 2022-03-11 14:52:04.990000             🧑  作者: Mango
public static void append(List list, Class cls) throws Exception {
E elem = cls.newInstance(); // OK
list.add(elem);
}
//You can invoke the append method as follows:
List ls = new ArrayList<>();
append(ls, String.class);