1 public class Test {
2 //属性:
3 int id;
4 static int sid;
5
6 //这是一个main方法,是程序的入口
7 public static void main(String[] args) {
8 //创建一个Test类的具体对象
9 Test t1 = new Test();
10 t1.id = 10;
11 t1.sid = 10;
12
13 Test t2 = new Test();
14 t2.id = 20;
15 t2.sid = 20;
16
17 Test t3 = new Test();
18 t3.id = 30;
19 t3.sid = 30;
20
21 //读取属性的值
22 System.out.println(t1.id);
23 System.out.println(t2.id);
24 System.out.println(t3.id);
25
26 System.out.println(t1.sid);
27 System.out.println(t2.sid);
28 System.out.println(t3.sid);
29 }
30 }
内存分析: