Java- Help with writing sudoko
<p>I'm trying to implement a Sudoko in java.</p>

<p>(there a Gui class that prints the matrix).</p>

<p>Here's an example for 2 methods that I wrote regarding the rows of the matrix(9X9).</p>

<p>When there's "-1" in a cell the method puts there a number that does not appear in the spesific row and if there is already a number it is update a boolean array to "true" in the place of the index that equales to the number (number can be between 1-9).</p>

<p>It stops after 4 loops, and I'm having a really hard time to realize why.</p>

<p>Can someone see what is wrong? Maybe a mistake of understanding something?</p>

<pre><code>public static boolean checkRow(int row, int[][] matr) {
    boolean[] ind = new boolean[9];
    Arrays.fill(ind, false);
    for (int j = 0; j &lt;= 8; j++) {
        if (matr[row][j] == -1) {

            int n = whatToputRow(row, matr);

            if (n == 0) {
                return false;
            } else {
                matr[row][j] = n;
                ind[n - 1] = true;
                System.out.print(n+" ");
            }
        } else {
            ind[matr[row][j] - 1] = true;
        }
    }

    return checkBoolean(ind);
}



    public static boolean checkBoolean(boolean[] mat) {
    for (int i = 0; i &lt;= 8; i++) {
        if (!mat[i]) {

            return false;
        }
    }
    return true;
}


    public static int whatToputRow(int row, int[][] mat) {

    for (int number = 1; number &lt;= 9; number++) {
        boolean bool = false;
        int i = 0;
        while (!bool &amp;&amp; i &lt;= 8) {
            if (mat[row][i] == number) {
                bool = true;
            } else {
                i = i + 1;
            }
        }
        if (bool == false)
            return number;

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