javaクラスのすべての印刷方法
静的なクラスを作成し、オブジェクトに入力します。オブジェクトのクラス名と実装方法を印刷してください。
印刷するオブジェクトクラスを作成します。
印刷するオブジェクトクラスを作成します。
package tian.parse.xml;
public class SaxParseXml{
public void one(){}
public void two(){}
public void three(){}
}
上のクラス名と実現方法を承諾します。package tian.method;
import java.lang.reflect.Method;
import tian.parse.xml.SaxParseXml;
public class GetMethod {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
SaxParseXml sax = new SaxParseXml();
getMethod(sax);
}
public static void getMethod(Object o) {
Class c = o.getClass();
//
System.out.println(c.getName());
Method[] m = c.getMethods();
//
for (Method method : m) {
System.out.println(method.getName());
}
}
}