- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHackerrankJava0060.java
More file actions
Latest commit
57 lines (46 loc) · 1.16 KB
/
Copy pathHackerrankJava0060.java
File metadata and controls
57 lines (46 loc) · 1.16 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
importjava.lang.reflect.Method;
importjava.util.ArrayList;
importjava.util.Collections;
publicclassHackerrankJava0060 {
publicstaticvoidmain(String[] args) {
// Java Reflection - Attributes
// https://www.hackerrank.com/challenges/java-reflection-attributes/problem?isFullScreen=true
// --- You need to update this line ---
Classstudent = Student01.class;
// --- You need to update this line ---
Method[] methods = student.getDeclaredMethods();
ArrayList<String> methodList = newArrayList<>();
// --- You need to update this line ---
for (Methodmethod : methods) {
// --- You need to update this line ---
methodList.add(method.getName());
}
Collections.sort(methodList);
for (Stringname : methodList) {
System.out.println(name);
}
}
}
classStudent01 {
privateStringname;
privateStringid;
privateStringemail;
publicStringgetName() {
returnname;
}
publicStringgetId() {
returnid;
}
publicStringgetEmail() {
returnemail;
}
publicvoidsetName(Stringname) {
this.name = name;
}
publicvoidsetId(Stringid) {
this.id = id;
}
publicvoidsetEmail(Stringemail) {
this.email = email;
}
}