java

리플렉션 메소드 사용, reflection

기계새 2013. 5. 6. 10:51

리플렉션 (Reflection)

자바의 코드 자체를 추상화 하여 접근하도록 만들어진 기능, Method.


 
String checkTarget = "Hello";
Method lengthMethod = String.class.getMethod("length");
int checker = (Integer)lengthMethod.invoke(checkTarget);
int compare = checkTarget.length();

---

checker와 compare는 같다.