회사서 Class를 조사할 일이 있는데 reflect를 까먹어서 한동안 googling 해서 다시 학습…
java.lang.String의 method를 출력하는 루틴의 골자만 요약하면….
import java.lang.reflect.*; public class ClassExam{ public void printClassInfo(String className){ try{ Class a = this.getClass().getClassLoader().loadClass(className); Method[] methods = a.getDeclaredMethods(); for(int i=0; i<methods.length; i++){ System.out.println(methods[i].toString()); } }catch(Exception e){ } } public static void main(String[] args){ ClassExam a = new ClassExam(); a.printClassInfo("java.lang.String"); } }