Copy Java array of one-dimensional two-dimensional

Copy the one-dimensional array

Arrays.copyOfRange(T[ ] original,int from,int to)

Arrays.copyOfRange(pre, 1, i + 1)

An original array of original, begin copying from the index from, copied to the mark to, generate a new array.

copyOfRange left and right closed interval open interval

Dimensional array defined: int array [] [] = new int [3] [3];

Get the number of rows: int rowLength = array.length;

Get the number of columns: int colLength = array [0] .length;

Copy of the two-dimensional array

 for (int i = 0; i < rowlength; i++) {
           System.arraycopy(arr[i], 0, matrix[i], 0,
            matrix.length);
        }
          

arrayCopy( arr1, 0, arr2, 0, 10);

Means; arr1 the array index from 0 beginning with the elements in the arr2 copied to the array index of 0, the number of elements 10 is copied.

Published 13 original articles · won praise 0 · Views 840

Guess you like

Origin blog.csdn.net/kelexing4/article/details/105377968