Searching A 'SubArray'
<p>I'm trying to create a function which will check a 3x3 block of array elements from a larger array for a specific element.</p>

<pre><code>9...84.6.  
..4..75.8  
.3.......  
3....1...  
.7.5.6.4.  
...4....2  
.......5.  
5.97..2..  
.8.21...4
</code></pre>

<p>I want to pass in a box numbered 0-8 and look for x within only the box selected. The puzzle array could be something like the above.</p>

<pre><code>protected static boolean box(int box, int x){
//box is a 3x3 subset of puzzle
//  012
//  345    &lt;--- boxes numbered as such
//  678
    boolean present = false;
    int coordR = 0, coordC = 0;

    switch (box){
        case 0:
            coordR = 0;
            coordC = 0; 
        case 1:
            coordR = 0;
            coordC = 3;
        case 2:
            coordR = 0;
            coordC = 6;
        case 3:
            coordR = 3;
            coordC = 0;
        case 4:
            coordR = 3;
            coordC = 3;
        case 5:
            coordR = 3;
            coordC = 6;
        case 6:
            coordR = 6;
            coordC = 0;
        case 7:
            coordR = 6;
            coordC = 3;
        case 8:
            coordR = 6;
            coordC = 6;
    }
    System.out.print("Box " + box + " -\t");
    for (int i = coordR; i &lt; 3; i++){
        for (int j = coordC; j &lt; 3; j++){
            if (puzzle[i][j] == x){
                present = true;
                }
            System.out.print(puzzle[i][j]);
        }
    }
    System.out.println("");
    return present;
}
</code></pre>

<p>Is there a more efficient way to do this/make this work?</p>
