使用反射获取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>()); }}
侃侃尔雅
富国沪深
相关分类