Question: Fix me the following JAVA codes with problems of: 1. method 'write(java.io.PrintStream)' is never used 2. String concatenation '+=' in loop public void write(PrintStream out)

Fix me the following JAVA codes with problems of:

1. method 'write(java.io.PrintStream)' is never used

2. String concatenation '+=' in loop

public void write(PrintStream out) { // Output matrix dimensions: height and width out.println(height + " " + width); // Output 'height' rows for (int i = 0; i < height; i++) { // Add first entry to the string representing the row String row = ""; if (width > 0) { row += matrix[i][0]; } // Add remaining entries to the string, separated by a space for (int j = 1; j < width; j++) { row += " " + matrix[i][j]; } // Output the row. out.println(row); } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!