Distinguish between assignment and copying of arrays
Let's start with the conclusion: Assignment is completely different from copying! !
Summary:
1. Assignment: just give the address of array1 to array2. If you modify array2, array1 will change too!
array2 = array1; //只是把array1的地址给了array2
//修改array2的话array1也会变!
2. Copy:
String[] arr = new String[] {
"hyj", "hxc", "hdh", "wt", "wtl", "yhp"};
//数组的复制(区别于数组变量的赋值:arr1 = arr)
String[] arr1 = new String[arr.length];
for(int i = 0;i < arr1.length;i++){
arr1[i] = arr[i];
}