ArrayMatrix extends AbstractMatrix<E> { @Override protected E read(int row, int col) { if (values[row][col] != null) { return (E) values[row][col]; } return null; } ArrayMatrix(int rows, int columns); @Override int getRows(); @Override int getColumns();  }
@Test public void testIterator() { for (MatrixRow<Integer> row : matrix) { for (MatrixCell<Integer> cell : row) { final int columnNumber = cell.getColumnNumber(); final int rowNumber = cell.getRowNumber(); assertThat(matrix.read(rowNumber, columnNumber), is(input[rowNumber][columnNumber])); } } }