1、数组操作中可以使用等于(=)赋值
注意:此时,新数组仅指向原始数组的存储空间,而不是重新申请新空间。
示例:公共类阵列测试{
publicstaticvoidmain (string args [ ] ) {
//1
int[] a=new int[4];
a[0]=1;
a[1]=2;
a[2]=3;
a[3]=4;
system.out.println(a[3];
//2
int b[]=new int[4];
b[0]=1;
b[1]=2;
b[2]=3;
b[3]=4;
system.out.println(b[2];
//3
int [ ] c={ 1,2,3,4 };
int [ ] d=new int [ ] { 1,2,3,4 };
系统. out.println (c [2];
system.out.println(d[3];
}
}
2、System.ararycopy方法使用System.ararycopy (原始阵列,0,目标阵列,0,原始阵列.长度);
注意:新数组将在复制原始数组中的数据之前重新申请存储地址空间。