温馨提示×

java输出换行的方法是什么

小亿
313
2024-03-20 17:03:17
栏目: 编程语言
Java开发者专用服务器限时活动,0元免费领,库存有限,领完即止! 点击查看>>

在Java中,输出换行可以采用以下几种方法:

  1. 使用System.out.println()方法:
System.out.println("Hello, World!");
System.out.println("This is a new line.");
  1. 使用System.out.print()方法结合使用转义字符"\n":
System.out.print("Hello, World!\n");
System.out.print("This is a new line.\n");
  1. 使用System.out.printf()方法结合使用转义字符"\n":
System.out.printf("Hello, World!%n");
System.out.printf("This is a new line.%n");

以上方法都可以在输出字符串后换行。

亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

推荐阅读:php echo输出换行的方法是什么

0