import java.lang.reflect.*;
public class testtest {
/**
* @param args
* @throws NoSuchMethodException
* @throws SecurityException
* @throws InvocationTargetException
* @throws IllegalAccessException
* @throws IllegalArgumentException
*/
public static void main(String[] args) throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException {
// TODO Auto-generated method stub
String func_name="";
testtest ttt = new testtest();
for(int i=0; i<3; i++) {
func_name="ppp"+(i+1);
Method method = testtest.class.getDeclaredMethod(func_name);
System.out.println(method.invoke(ttt, new Object[]{}));
}
}
String ppp1(){
System.out.println("ppp1호출");
return "ppp1";
}
String ppp2() {
System.out.println("ppp2호출");
return "ppp2";
}
String ppp3() {
System.out.println("ppp3호출");
return "ppp3";
}
}
참으로 Exception이 많구나..;;
댓글 없음:
댓글 쓰기