public class Matrix { public static void main(String[] args) { for (int w = 1; w < 10; w++) { for (int q = 1; q < 10; q++) { System.out.print(q * w + " "); } System.out.println(); } } } - A small note. The explanation in the answer you received is not entirely correct. Moreover, for Windows and MacOS (classic, up to version 9) it is not true. If absolutely simple analogies are given, then println performs "virtual pressing of the enter button". Those. in * nix systems, it prints "\ n", in windows "\ r \ n" in old MacOS "\ r". Ignoring this nuance leads to problems extremely rarely, but at the same time it is extremely painful. - rjhdby
|
1 answer
This is a line
System.out.println(); displays a newline character, thereby making the transition to a new line.
For example, you could write
System.out.println( "" ); These two function calls are actually equivalent.
You could do the same thing using the print function. For example,
System.out.print( "\n" ); - This is how to understand the newline character? Those. the conclusion that is in the scope of the second cycle, builds a row for column 1. And this turns out to build columns? - hellog888
- As far as I remember from reading my book on C ++, then it says there that until the second cycle completes its cycle, the external one will not move to the position indicated in the cycle. - hellog888
- @HelloGoogle In the internal loop, the data is displayed on one line immediately after each other. After this cycle, the println function converts to a new line by placing the character '\ n' into the output stream, which is considered by the stream as a control character, which indicates that the cursor needs to be transferred to a new line. - Vlad from Moscow
- That is, in the future, if you use an empty output, this will always mean ("\ n"); ? - hellog888
- 3a little remark. print ("\ n") is not analogous to println (), since the latter uses the system property "line.separator" which may vary depending on the platform. - Artem Konovalov
|