Java syntax error on tokens, misplaced constructs - array initialization

Hanmyo picture Hanmyo · Dec 11, 2010 · Viewed 14k times · Source

I have the following code in Java 5:

for (Object o : theList) {
    for (int k=0; k<theList.size(); k++)
        int[][] m = new int[7][7];
    m = theList.get(k);
    for (int i=0; i<7; i++) {
        for (int j=0; j<7; j++) {
            System.out.println(m[i][j]);
        }
        System.out.println();
    }
    System.out.println();
}
...
}

On the line with

int[][] m = new int[7][7]

it is telling me "Syntax error on token(s), misplaced construct(s)". Any idea what I'm doing wrong? Thanks.

Answer