class AbstractMatrix implements Matrix {

    protected void checkBounds(int i, int j) {
        if (i < 0 || i >= getRowCount()) {
            throw new IllegalArgumentException("Row index out of bound [0, " + (getRowCount() - 1) + "]");
        }
        if (j < 0 || j >= getColumnCount()) {
            throw new IllegalArgumentException("Column index out of bound [0, " + (getColumnCount() - 1) + "]");
        }
    }

}