使用反射获取Java中泛型参数的类型
public final class Voodoo {
public static void chill(List<?> aListWithTypeSpiderMan) {
// Here I'd like to get the Class-Object 'SpiderMan'
Class typeOfTheList = ???;
}
public static void main(String... args) {
chill(new ArrayList<SpiderMan>());
}}
不负相思意
侃侃尔雅
富国沪深
随时随地看视频慕课网APP
相关分类