import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;

public class Main
{
   static <A,B> void addAll(Collection<B> dest, Collection<A> source, String methodName)
          throws IllegalAccessException, InvocationTargetException, NoSuchMethodException
   {
      Method m = null;
      for (A a: source)
      {
         if (m == null)
            m = a.getClass().getMethod(methodName);
         dest.add((B)m.invoke(a));
      }
   }
   
   public static void main(String[] args) throws Exception
   {
      ArrayList<String> s = new ArrayList<String>();
      List<Integer> i = Arrays.asList(1,2,3);
      addAll(s, i, "toString");
      System.out.println(s);
   }
}