使用反射的泛型类中的泛型方法
/**from 时 代 J a v a**/ import java.util.*; class ExampleMethods<T> { public boolean simpleMethod(String stringParam, int intParam) { System.out.println("String: " + stringParam + ", integer: " + intParam); return true; } public int varArgsMethod(String... manyStrings) { return manyStrings.length; } public boolean methodWithList(List<String> listParam) {/**时 代 J a v a - N o w J a v a . c o m**/ return listParam.isEmpty(); } public <T> void genericMethod(T[] a, Collection<T> c) { System.out.println("Length of array: " + a.length); System.out.println("Size of collection: " + c.size()); } }