how to get int[][] dimensionArray?
<p>I want to get matrix[i][j] to my int[][] gettwodimensionalArray, I try so many way, but when I do the test, my gettwodimensionaArray still not store from matrix[i][j]. Please help me out, thank you. </p>

<p>Here is my code look like. </p>

<pre><code>    public int[][] gettwodimensionalArray(String file_name) {
    File file = new File(file_name);
    ArrayList&lt;int[]&gt; rows = new ArrayList&lt;int[]&gt;();
    try {
        Scanner scanner = new Scanner(file);
        while (scanner.hasNextLine()) {
            String line = scanner.nextLine();
            String[] s = line.split("\\s+");
            int[] row = new int[s.length];
            for (int i = 0; i &lt; s.length; i++) {
                row[i] = Integer.parseInt(s[i]);
            }
            rows.add(row);
            System.out.println(line);
        }
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }
    int numbOfRow = rows.size();
    // find number of columns by gettting the lenght of one of the rows row

    int keepTrackSizeFirstRow;
    for (int i = 0; i &lt; numbOfRow; i++) {
        if (i == 0) {
            keepTrackSizeFirstRow = rows.get(0).length;

        }
        // compare current row i's array length, to keetracksizefirstrow
    }

    int[][] matrix = new int[numbOfRow][rows.get(0).length];
    // System.out.println(matrix);

    for (int i = 0; i &lt; numbOfRow; i++) {
        // i = row

        for (int j = 0; j &lt; rows.get(i).length; j++) {
            // j = col

            matrix[i][j] = rows.get(i)[j];
            System.out.print(matrix[i][j]);

        }
    }
    return matrix;
}
</code></pre>
