第一种自己敲,直接按sop直接输出的是System.out.printf
public class Hello {
public static void main(String[] args) {
System.out.printf("hello,world!");
// 输出语句
}}
打印输出如下,没有换行
hello,world!
进程已结束,退出代码0
对比课程上的第二种按按sop应该输出的是System.out.println
public class Hello {
public static void main(String[] args) {
System.out.println("hello,world!");
// 输出语句
}}
打印输出如下,有换行
hello,world!
进程已结束,退出代码0
本文详细介绍了Java中两种常用的打印语句:System.out.printf和System.out.println的区别及使用场景。通过具体的代码示例展示了如何使用这两种方法进行字符串的输出,并对比了它们在输出结果上的不同之处。
24万+

被折叠的 条评论
为什么被折叠?



