Java 得到一个类里面的方法和属性

来源:互联网 发布:手游推荐知乎 编辑:程序博客网 时间:2024/04/30 04:58
TestCase tc =new TestCase();
    Method[] methods =tc.getClass().getDeclaredMethods();
   
    for(Method method : methods)
    {
     System.out.println(method.getName());
    }
   
    Field[] fields=tc.getClass().getDeclaredFields();
    for(Field field : fields)
    {
     System.out.println(field.getName());
    }
 }