File tree Expand file tree Collapse file tree 2 files changed +57
-2
lines changed
java_test/src/main/java/com/yiyun Expand file tree Collapse file tree 2 files changed +57
-2
lines changed Original file line number Diff line number Diff line change 1+ package com .yiyun ;
2+
3+ import java .lang .reflect .Field ;
4+
5+ /**
6+ * @class: ClassTest
7+ * @description: Class 测试
8+ * @author: yi-yun
9+ * @create: 2019-09-07 14:29
10+ **/
11+ public class ClassTest {
12+ private static int [] array = new int [3 ];
13+ private static int length = array .length ;
14+ private static Class <One > one = One .class ;
15+ private static Class <Another > another = Another .class ;
16+
17+ public static void main (String [] args ) throws Exception {
18+ One oneObject = ClassTest .one .newInstance ();
19+ oneObject .call ();
20+
21+ Another anotherObject = ClassTest .another .newInstance ();
22+ anotherObject .speak ();
23+
24+ Field inner = one .getDeclaredField ("inner" );
25+ inner .setAccessible (true );
26+
27+ inner .set (oneObject , "world change" );
28+ System .out .println (oneObject .getInner ());
29+
30+ }
31+ }
32+
33+ class One {
34+ private String inner = "time flies..." ;
35+
36+ public void call () {
37+ System .out .println ("hello world" );
38+ }
39+
40+ public String getInner () {
41+ return inner ;
42+ }
43+ }
44+
45+ class Another {
46+ public void speak () {
47+ System .out .println ("easy coding..." );
48+ }
49+ }
Original file line number Diff line number Diff line change 44
55public class TestStringBuffer {
66 @ Test
7- public void fun (){
7+ public void fun () {
88 final StringBuffer stringBuffer = new StringBuffer ("yi-yun" );
99 System .out .println ("stringBuffer = " + stringBuffer .hashCode ());
1010 stringBuffer .append ("hello" );
1111 System .out .println ("stringBuffer = " + stringBuffer .hashCode ());
12-
12+ }
13+
14+ @ Test
15+ public void fun1 () {
16+ String a = "hello" ;
17+ String b = "hello" ;
18+ System .out .println (a == b );
1319 }
1420}
You can’t perform that action at this time.
0 commit comments