forked from PacktPublishing/Java-Coding-Problems
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
30 lines (21 loc) · 760 Bytes
/
Main.java
File metadata and controls
30 lines (21 loc) · 760 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
30
package modern.challenge;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.List;
public class Main {
public static void main(String[] args) throws ReflectiveOperationException {
List<Method> staticMethods = new ArrayList<>();
Class<Melon> clazz = Melon.class;
Method[] methods = clazz.getDeclaredMethods();
for (Method method : methods) {
if (Modifier.isStatic(method.getModifiers())) {
staticMethods.add(method);
}
}
System.out.println(staticMethods);
System.out.println();
Method method = clazz.getMethod("peel", Slice.class);
method.invoke(null, new Slice());
}
}