-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestReflect.java
More file actions
59 lines (50 loc) · 1.29 KB
/
TestReflect.java
File metadata and controls
59 lines (50 loc) · 1.29 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
58
59
package reflect;
import java.lang.reflect.Field;
import java.util.*;
//import java.lang.Class;
public class TestReflect {
public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException, NoSuchFieldException, SecurityException {
// TODO Auto-generated method stub
Object d=new Date();
Class cl1=d.getClass();
String name=cl1.getName();
System.out.println(d);
System.out.println("1"+name);
//
// String className="java.util.Date";
// Class cl2=Class.forName("java.util.Date");
// System.out.println("2"+cl2.getName());
//
// Class cl3=Date.class;
// System.out.println("3"+cl3.getName());
//
// Class cl4=double[].class;
//// Class cl4=int[].class;
// System.out.println("4"+cl4.getName());
//
// if(cl3==cl2)
// System.out.println("ÒýÓÃÒ»Ñù");
//
// Date dd=(Date)cl3.newInstance();
// System.out.println(dd);
System.out.println("*****************************************************");
// A a=new A();
// Class cl=a.getClass();
// Field f=cl.getDeclaredField("n");
// f.setAccessible(true);
// Object test=f.get(a);
// System.out.println(test);
//
// int[] test={2,3,4};
// System.out.println(test.getClass().getName());
//
}
}
class A{
public int m;
private int n;
public A(){
m=3;
n=6;
}
}