-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainReflection.java
More file actions
20 lines (17 loc) · 845 Bytes
/
MainReflection.java
File metadata and controls
20 lines (17 loc) · 845 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import com.dofler.webapp.model.Resume;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
public class MainReflection {
public static void main(String[] args) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
Resume resume = new Resume("FullName");
Field firstFieldResume = resume.getClass().getDeclaredFields()[0];
firstFieldResume.setAccessible(true);
System.out.println(firstFieldResume.getName());
System.out.println(firstFieldResume.get(resume));
firstFieldResume.set(resume, "new uuid");
System.out.println(firstFieldResume);
Method methodToStringResume = resume.getClass().getMethod("toString");
System.out.println(methodToStringResume.invoke(resume));
}
}