You can do almost anything with recursion if you care to headache your way through the logic of it. In this case it shouldn't be too hard
private boolean checkForValue(int val, int row, int col){
if(row == numRows && col == numCols)
return false;
else{
if(values[row][col] == val)
return true
else if(col < (numCols - 1))
checkForValue(val, row, col + 1);
else
checkForValue(val, row + 1, 1);
}
}
However, if you are just wanting to save time I think the for loop really is pretty efficient to start
private boolean checkForValue(int val){
for(int i = 0; i < numRows; i++){
for(int j = 0; j < numCols; j++){
if(values[i][j] == val) return true;
}
}
return false; //it will reach here if return true was not called.
}
Neither is too rough.
contains()uses a loop internally.