关于一个方法应用于一个序列的问题
程序代码:
package package_1; import java.util.*; public class Shape { public void drawing(){ System.out.println("Shape"); } }package package_1; import java.util.*; public class FilledList<T> extends ArrayList<T> { public FilledList(Class<? extends T> type,int size){ try{ for(int i=0;i<size;i++) add(type.newInstance()); }catch(Exception e){ throw new RuntimeException(e); } } }package package_1; import java.lang.reflect.*; import java.util.*; public class Apply { public static <T,S extends Iterable<? extends T>> void apply(S seq,Method f,Object...args){ try{ for(T t:seq) f.invoke(t,args); }catch(Exception e){ throw new RuntimeException(e); } } }package package_1; import java.util.*; import java.lang.reflect.*; public class mymain { public static void main(String[] args) throws Exception{ FilledList<Shape> shapes=new FilledList<Shape>(Shape.class,5); Apply.apply(shapes,Shape.class.getMethod("drawing")); } }
请问Apply.apply中为什么还要设置一个泛型T,以及Iterable<?extends T?
请教大师