Java Reflection - Attributes

  • + 6 comments
        public static void main(String[] args){
            Class student = Student.class;
            Method[] methods = student.getDeclaredMethods();
    
            ArrayList<String> methodList = new ArrayList<>();
            for(Method m : methods){
                methodList.add(m.getName());
            }
            Collections.sort(methodList);
            for(String name: methodList){
                System.out.println(name);
            }
        }