I have a String[][] type array, like this,
static final String arrChildelements[][] = {
{ "1", "2", "3"..... },
{ "A", "B", "C"..... },
{ "X", "Y", "Z"..... } };
Here the number of rows is fixed i.e. 3. Now I want to store this Array in some other Array of the same type. What I have done so far is,
for (int i = 0; i < 3; i++) {
for (int j = 0; j < secondColumnLength; j++) {
//Here I have no idea that how to get the number of elements for the column
arrChild[i][j] = arrChildelements[i][j];
}
}
So far, I can only remember this method to iterate through the String[][] array. Though I would love to know if there is any other good way to accomplish this.
Instead of iterating over each member of an array, instead use
System.arraycopy():Additionally, if you must iterate over each value,
arrChildElements.lengthis your outer loop value, andarrChildElements[i].lengthis your inner loop value.