-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGenNormalObject2.java
More file actions
executable file
·32 lines (30 loc) · 1.05 KB
/
GenNormalObject2.java
File metadata and controls
executable file
·32 lines (30 loc) · 1.05 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
/* */ package reflection;
/* */
/* */ import java.lang.reflect.Field;
/* */
/* */ public class GenNormalObject2
/* */ {
/* */ public static void main(String[] args) {
/* */ try {
/* 9 */ Test testObj = new Test();
/* 10 */ System.out.println(testObj);
/* */
/* 12 */ Class<?> c = testObj.getClass();
/* 13 */ Object anotherObj = c.newInstance();
/* 14 */ System.out.println(anotherObj);
/* 15 */ System.out.println((c == anotherObj.getClass()));
/* */
/* 17 */ System.out.println("Now change value i using reflection.");
/* 18 */ Field field = c.getDeclaredField("i");
/* 19 */ field.set(anotherObj, new Integer(10));
/* 20 */ System.out.println(anotherObj);
/* */ }
/* 22 */ catch (Exception e) {
/* 23 */ e.printStackTrace();
/* */ }
/* */ }
/* */ }
/* Location: /Volumes/TXS.128G/hope useful/practice/2020.jar!/reflection/GenNormalObject2.class
* Java compiler version: 8 (52.0)
* JD-Core Version: 1.1.3
*/