Skip to content

Commit 7f66c89

Browse files
committed
add machugaoxiao code
1 parent b0b6c04 commit 7f66c89

File tree

2 files changed

+57
-2
lines changed

2 files changed

+57
-2
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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+
}

java_test/src/main/java/com/yiyun/TestStringBuffer.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,17 @@
44

55
public 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
}

0 commit comments

Comments
 (0)