打印方式
//package com.nowjava;/** 时 代 J a v a 公 众 号 - nowjava.com 提供 **/ import java.lang.reflect.*; import static java.lang.System.out; public class Main { public static void printMethods(Class<?> c) { out.format("Methods => %n"); Method[] methods = c.getDeclaredMethods(); if (methods.length == 0) { out.format(" --%s", "No declared method found"); } else { for (Method m : methods) { Parameter[] params = m.getParameters(); StringBuffer sb = new StringBuffer(); if (params.length != 0) { int i = 0; for (; i < params.length - 1; i++) { sb.append(params[i].getType().getCanonicalName() + " " + params[i].getName()); /** * N o w J a v a . c o m 提 供 **/ sb.append(", "); } sb.append(params[i].getType().getCanonicalName() + " "