Returns the entry of this matrix located at the given one-based row and column indexes. Throws an exception if row or col is not 1 or 2.
public double get(int row, int col){
if (row != 1 || row != 2){
throw IndexOutOfBoundsException("Row not valid");
}
if (col != 1 || col != 2){
throw IndexOutOfBoundException("Column not valid");
}
return data[row - 1][col - 1];
}
This is the code for my method, but even if I call the method with the parameters row = 1, and col = 2; it shows an IndexOutOfBoundsException. Any ideas on how to fix this?