public class Test {
public static void main(String[] args){
String str1 = "hello";
String str2 = "world";
// print() 下一行打印不换行
System.out.print("不换行:");
// pringln()下一行打印换行
System.out.println(str1);
System.out.println(str2);
System.out.println("---------------------");
// "\n" 换行符
System.out.print(str1 + "\n" + str2);
}
}
结果:
不换行:hello
world
---------------------
hello
world
\n 转义字符