### Question:
SparseMatrix extends Matrix { @Override public String toString() { final StringBuilder builder = new StringBuilder(); builder.append(String.format("[%d x %d]", this.getRowCount(), this.getColumnCount())); this.forEach((r, c, v) -> builder.append(formatEntry(r, c, v))); return builder.toString(); } SparseMatrix(final int numRows, final int numCols, final int initialCapacityPerRow); @Override final void forEach(final ReadOnlyElementVisitorFunction func); @Override MatrixNonZeroElementRowIterator getNonZeroElementRowIterator(final int row); int getNonZeroColumnCount(final int row); int getRowCapacity(final int row); @Override String toString(); int getNumEntries();  }### Answer:
@Test public void sparseMatrixStringRepresentationIsCorrect() { final Matrix matrix = this.createMatrix(3, 2, new double[] {2.1234, 11.1234, 0, 1, 5012.0126, 0}); final String expectedString = "[3 x 2]" + System.lineSeparator() + "(0, 0) -> 2.123" + System.lineSeparator() + "(0, 1) -> 11.123" + System.lineSeparator() + "(1, 1) -> 1.000" + System.lineSeparator() + "(2, 0) -> 5012.013"; MatcherAssert.assertThat(matrix.toString(), IsEqual.equalTo(expectedString)); }