This function is supposed to get the indices of a matched element in a 2D array (`OriginalArray`). But because of duplicates, it keeps on scanning the values and ultimately replacing the indices assigned to variables `a,b` with the last element found. How can I get to store the index of value matched first and then stop searching?. 

This might be simple for you,

OriginalArray 

```
15 15 14 15 12 06 12
14 13 10 12 15 17 15
15 15 09 11 08 15 15
16 17 08 16 15 07 05
19 18 19 18 17 15 14

```

Code:

```
int row=5;
int col=7;
int [][] OriginalArray = new int [row][col];

int a=0,b=0;
for ( int i = 0; i < row; ++i ) {
    for ( int j = 0; j < col; ++j ){
        if( OriginalArray[i][j] == 8  ) {
            // Found the correct i,j - print them or return them or whatever
        System.out.println("{"+i+","+j+"}");
    System.out.println();
            a=i;
            b=j;
            break;
        } 
    }
}

```