forked from hcientist/OnlinePythonTutor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReflect.java
More file actions
15 lines (14 loc) · 456 Bytes
/
Reflect.java
File metadata and controls
15 lines (14 loc) · 456 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import java.lang.reflect.*;
public class Reflect {
public static void announce() {
System.out.println("Someone called announce().");
}
public static void main(String[] args) {
try {
Method m = Reflect.class.getMethod("announce", null);
m.invoke(null); // null "this" since it's a static method
}
catch (NoSuchMethodException | IllegalAccessException
| InvocationTargetException e) {}
}
}