biryu2205 / Biryu

0 stars 0 forks source link

Hackerrank - Java Reflection - Attributes #105

Closed biryu2205 closed 6 years ago

biryu2205 commented 6 years ago
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);
    }
  }
}

Link : - https://www.hackerrank.com/challenges/java-reflection-attributes/problem