You are viewing a single comment's thread. Return to all comments →
You are assigning a line of string into a 1D array. Then how does it automatically become a 2D array?
The code does not assign the line of string into a 1D array. In the code, charArray is a 2D array (an array of arrays). The line which has "charArray[i] = lines.toCharArray" converts the string to an array of characters, and this array of characters is then stored in charArray[i]. Hence, filling the i-th position of the 2D array.