Skip to content

Commit 0408832

Browse files
understand class in java
1 parent e7add79 commit 0408832

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/**
2+
* This is a class to help me understand "CLASS" in java.
3+
*/
4+
package sporadic;
5+
6+
/**
7+
* @author SteveSun
8+
*
9+
*/
10+
public class UnderstandClass {
11+
12+
/**
13+
*
14+
*/
15+
public UnderstandClass() {
16+
}
17+
18+
/**
19+
* @param args
20+
*/
21+
public static void main(String[] args) {
22+
UnderstandClass uc = new UnderstandClass();
23+
Class c1 = UnderstandClass.class;
24+
Class c2 = uc.getClass();
25+
System.out.println(c1);
26+
System.out.println(c2);
27+
System.out.println(c1 == c2);
28+
Class c3 = null;
29+
try {
30+
c3 = Class.forName("sporadic.UnderstandClass");
31+
} catch (ClassNotFoundException e) {
32+
e.printStackTrace();
33+
}
34+
System.out.println(c3);
35+
System.out.println("End of the program.");
36+
}
37+
38+
}

0 commit comments

Comments
 (0)