package ming;import java.util.ArrayList;import java.util.Collection;public class GenericMethodTest { static void fromArraytoCollection(T[] a, Collection c) { for (T o : a) { c.add(o); } } public static void main(String[] args) { // TODO Auto-generated method stub //T stand for Object Object[] oa = new Object[100]; Collection
package ming;import java.util.ArrayList;import java.util.Collection;import java.util.List;public class GenericMethodTest { static void fromArraytoCollection(Collection from, Collection to) { for (T ele : from) { to.add(ele); } } public static void main(String[] args) { List ao = new ArrayList(); List as = new ArrayList (); // string is subclass of object fromArraytoCollection(as, ao); }}