Linux 拨号vps windows公众号手机端

java输出换行的方法是什么

lewis 9年前 (2016-11-09) 阅读数 11 #程序编程
文章标签 Java

在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");

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

版权声明

本文仅代表作者观点,不代表米安网络立场。

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

热门