I wonder if can I copy a 3-dimensional array, using ArrayList<>() as a middle step.
Please, consider the following code:
/*variable declaration*/
int[][][] array;
int[][][] array2;
ArrayList<int[][][]> list;
ArrayList<int[][][]> list2;
/*initialization*/
array = new int[10][12][14];
list = new ArrayList<>();
list.add(array);
//Construct 'list2', using all the elements contained in 'list'
list2 = new ArrayList(list);
array2 = list2.get(0);
I wonder if array2 is a complete copy (deep copy) of array, or is array2 a reference to array (points to same object in memory).
Also, is this an unsafe operation?