Java tutorial
//package com.java2s; //License from project: Apache License import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; public class Main { private static List<Object> createParamsArray(Method m, List<Object> availableParams) { List<Object> params = new ArrayList<Object>(); Class<?>[] paramTypes = m.getParameterTypes(); for (Class<?> type : paramTypes) { for (Object param : availableParams) { if (param != null && type.isAssignableFrom(param.getClass())) { params.add(param); } } } return params; } }