Java Reflection - Attributes

  • + 0 comments
    class Solution {
    
        public static void main(String[] args){
            Class student = new Student().getClass();
            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);
            }
        }
    }