Java Reflection - Attributes

  • + 0 comments

    Using java 7:

    public static void main(String[] args) throws ClassNotFoundException {
            Class student = Class.forName("Student");
            Method[] methods = student.getDeclaredMethods();
    
            ArrayList<String> methodList = new ArrayList<>();
            for(Method method : methods){
                methodList.add(method.getName());
            }
            Collections.sort(methodList);
            for(String name: methodList){
                System.out.println(name);
            }
    
    }