打印类的方法
/**from 时代Java公众号 - N o w J a v a . c o m**/ //package com.nowjava; import java.lang.reflect.Method; public class Main { public static void main(String[] argv) throws Exception { String clazz = "nowjava.com"; printMethodsForClass(clazz); } public static void printMethodsForClass(final String clazz) { try { final Class<?> util = Class.forName(clazz); System.out.println("Methods for " + clazz);/**from 时 代 Java 公 众 号 - nowjava.com**/ final Method[] methods = util.getMethods(); for (final Method method : methods) { String sep = ""; final StringBuilder buf = new StringBuilder(); final Class<?>[] types = method.getParameterTypes(); for (int i = 0, n = types.length; i < n; ++i) { buf.append(sep); buf.append(types[i].getName()); sep = ", "; }