慕标5832272
用反射机制,简单写了一个例子,不懂的可以看一下相关api public class OwerMethodParam {public static void main(String[] args) {new OwerMethodParam().test("bb");}public void test(String aa) {Method[] methods = OwerMethodParam.class.getDeclaredMethods(); //取得这个类的所有方法if (methods != null) {for (int i = 0; i < methods.length; i++) {Method method = methods[i];if ("test".equals(method.getName())) { //取得本方法,这个方法是test,所以就用test比较Class<?>[] paramsClass = method.getParameterTypes(); //取得参数列表的所有类if (paramsClass != null) {for (Class<?> class1 : paramsClass) {System.out.println(class1.getName());}}break;}}