Java Reflection - Attributes

윤지현·2025년 5월 8일
0

HackerRank[Java]

목록 보기
55/57
  • 문제
  • 정답
public class Solution {

        public static void main(String[] args){
            Class student = Student.class;
            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);
            }
        }

    }
  • 결과
profile
첫 시작

0개의 댓글