+ 2

How to make the output inline of 3s?

Like this 1 2 3 4 5 6 7 8 9 https://code.sololearn.com/cTOnc4h1ZaHo/?ref=app

14th Nov 2022, 2:29 AM
Mozzie
Mozzie - avatar
1 Answer
+ 3
for(int i = 0; i<matrix.length; i++){ for(int j =0; j<matrix.length; j++){ System.out.print(matrix[i][j] + " "); } System.out.println(); } Explanation: println adds a line break after each number, but print doesn't. So in the inside you only print a number and a space. After the inner loop you println nothing, which pushes the cursor to the next line.
14th Nov 2022, 3:45 AM
Tibor Santa
Tibor Santa - avatar