-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArrayTest.java
More file actions
57 lines (50 loc) · 1.26 KB
/
ArrayTest.java
File metadata and controls
57 lines (50 loc) · 1.26 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
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
定义第一个数组,赋值,输出
定义第二个数组,赋值,输出
定义第三个数组,把第一个数组的地址值赋值给它。注意,类型要一致
通过第三个数组的名称,给元素重新赋值,最后输出第一个的数组名称和元素
栈内存的两个引用指向同一个堆内存空间,无论是他们谁的操作,都是指向同一个地方
*/
class ArrayTest{
public static void main(String[] args){
int[] a=new int[4];
a[0]=9;
a[1]=8;
a[2]=67;
a[3]=56;
System.out.println(a);
System.out.println(a[0]);
System.out.println(a[1]);
System.out.println(a[2]);
System.out.println(a[3]);
System.out.println();
int[] b=new int[5];
b[0]=1;
b[1]=5;
b[2]=45;
b[3]=78;
b[4]=96;
System.out.println(b);
System.out.println(b[0]);
System.out.println(b[1]);
System.out.println(b[2]);
System.out.println(b[3]);
System.out.println(b[4]);
System.out.println();
int[] c=a;
c[0]=7;
c[1]=12;
c[2]=45;
c[3]=23;
System.out.println(c);
System.out.println(a[0]);
System.out.println(a[1]);
System.out.println(a[2]);
System.out.println(a[3]);
System.out.println();
System.out.println(c[0]);
System.out.println(c[1]);
System.out.println(c[2]);
System.out.println(c[3]);
}
}