-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path_00_ClassDemo.java
More file actions
executable file
·44 lines (42 loc) · 1.11 KB
/
_00_ClassDemo.java
File metadata and controls
executable file
·44 lines (42 loc) · 1.11 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
/* */ package reflection;
/* */
/* */ public class _00_ClassDemo {
/* */ public static void main(String[] args) {
/* 5 */ Foo foo1 = new Foo(1);
/* */
/* */
/* */
/* */
/* 10 */ Class<Foo> c1 = Foo.class;
/* */
/* */
/* */
/* 14 */ Class<?> c2 = foo1.getClass();
/* */
/* */
/* 17 */ System.out.println((c1 == c2));
/* */
/* */
/* 20 */ Class<?> c3 = null;
/* */ try {
/* 22 */ c3 = Class.forName("reflection.Foo");
/* 23 */ System.out.println((c2 == c3));
/* 24 */ } catch (ClassNotFoundException cnfe) {
/* 25 */ cnfe.printStackTrace();
/* */ }
/* */
/* */
/* */
/* */ try {
/* 31 */ Foo foo2 = c1.newInstance();
/* 32 */ System.out.println(foo2);
/* 33 */ foo2.print();
/* 34 */ } catch (Exception e) {
/* 35 */ e.printStackTrace();
/* */ }
/* */ }
/* */ }
/* Location: /Volumes/TXS.128G/hope useful/practice/2020.jar!/reflection/_00_ClassDemo.class
* Java compiler version: 8 (52.0)
* JD-Core Version: 1.1.3
*/