- Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathJavaReflectionAttributes.java
More file actions
Latest commit
29 lines (24 loc) · 802 Bytes
/
Copy pathJavaReflectionAttributes.java
File metadata and controls
29 lines (24 loc) · 802 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// https://www.hackerrank.com/challenges/java-reflection-attributes/problem
importjava.lang.reflect.Method;
importjava.util.ArrayList;
importjava.util.Arrays;
importjava.util.Collections;
publicclassJavaReflectionAttributes {
publicstaticvoidmain(String[] args) {
Classstudent = Student.class;
Method[] methods = student.getDeclaredMethods();
ArrayList<String> methodList = newArrayList<>();
for(Methodmethod : methods){
methodList.add(method.getName());
}
Collections.sort(methodList);
for(Stringname: methodList){
System.out.println(name);
}
}
privatestaticclassStudent {
publicvoidgetName() {}
publicvoidsetName() {}
privatevoidsetAge() {}
}
}