1、\t 制表符
\t?制表符,8个字节(8个英文状态下的空格)
public class Test {
public static void main(String [] args) {
/*Java中的字符使用的是Unicode编码*/
System.out.println("helloworld");
System.out.println("hello\tworld"); //hello占5个字符,8个空格没有占满,所以\t出来3个字符的位置
System.out.println("helloooo\tworld");//helloooo占满了8个,会重新开一个制表位
System.out.println("helloworld");
System.out.println("张\t三"); //一个汉字占2个空格 \t出来6个空格的位置
}
}
输出结果?
helloworld
hello world
helloooo world
helloworld
张 三
2、\n 换行
println():只能在输出之后换一行
\n :位置可在前,中,后,可以写多个
public class Test {
public static void main(String [] args) {
// System.out.println("helloworld"); 输出之后自动换一行
System.out.print("\n\nhelloworld\n\n\nhelloworld"); //每个\n换一行
}
}
3、\" 输出时显示一个"
4、 \\ 输出时显示一个\
public class Test {
public static void main(String [] args) {
// System.out.println("helloworld"); 输出之后自动换一行
System.out.print("\n\nhelloworld\n\n\nhelloworld"); //每个\n换一行
System.out.println("老师说:\"好好学习\"");
System.out.println("http:\\\\www.baidu.com");
}
}