System.out.print("*")和System.out.println("*")有什么區(qū)別啊,為什么print這里輸出的是橫向的,println輸出的就是縱向的呢?
public class HelloWorld {
? ? public static void main(String[] args) {? ?
?for (int i=1;i<4;i++) {
? ? ? ? ? ? for (int j = 1; j < 9; j++) {
? ? ? ? ? ? ? ? System.out.print("*");
? ? ? ? ? ? }
? ? ? ? ? ? System.out.println();
? ? ? ? }
}
}
2020-12-14
System.out.print("*")是直接輸出 *,引號(hào)里面有幾個(gè)*就輸出幾個(gè);
System.out.println("*")是先換行,然后再輸出 *,
引號(hào)里面有幾個(gè)*就輸出幾個(gè)。
2023-06-10
ln就是換行,雖然都是輸出語句。
2021-01-17
ln相當(dāng)于換行,當(dāng)然ln可以輸出空格后的代碼,而只有print不能輸出空格后的代碼,比如輸出hello world
2020-12-11
這就是一個(gè)設(shè)定ln是就相當(dāng)于換行的意思