Because the array is of the reference type, assigning a value using the array1 = array2 method will direct array1 and array2 to the same memory space. Changing the elements of array1 and array2 will modify the same memory space.
However, we often want the replication effect. We only want the elements of array1 to be the same as those of array2. Then we can use a loop to make array1 [I] = array2 [I] one by one.
Or use the copyto method to copy:
Array2.copyto (array1, 0); // copy all the contents of the array2 array to array1 and insert it from element 0th of array1.
By the wayString Transmission Method:
String is also a reference type, but a new space is automatically created when the string value is assigned.
For example, string a = '"123 ";
String B =;
In this case, the address of B is different from the address of a. the compiler automatically creates a new space for B and copies the content of a to the space of B. This is not the same as the simple reference transfer method for arrays. It is special for strings.