Java Reflection - Attributes

  • + 1 comment

    //can anyone tell me why error is coming in this code?? import java.util.; import java.lang.reflect.; public class Solution {

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