我可以使用java反射來查看類的方法。使用Java反射查看方法的實現(方法體)
Method[] methods = Person.class.getMethods();
for(Method method : methods){
System.out.println("method = " + method);
}
的person
類,
class Person{
String name;
int age;
Person(String name,int age){
this.name = name;
this.age = age;
}
public int count(){
int count = 10*20;
return count;
}
}
使用反射的count
方法將觀看等, method = public int Person.count()
但不實施(方法體)。
有無論如何查看使用這種方法或任何其他方法的完整實現細節?