转移序列是用于向设备或程序发送指令的字符序列,这种序列以反斜杠()起始,该字符叫做转移字符,转义序列不仅可用于文本格式化,而且可用于特殊目的。
转义序列 | 描述 |
---|---|
\t | 插入制表符 |
\\ | 插入反斜杠 |
\‘ | 插入单引号 |
\“ | 插入双引号 |
\r | 插入回车 |
\n | 插入新行 |
\b | 插入退格符 |
\f | 插入换页(form feed) |
System.out.println("Linefeed: \nlearning java");
System.out.println("single quote: \'learning java\'");
System.out.println("double quote: \"learning java\"");
System.out.println("backslash: \\learning java\\");
System.out.println("制表符: learning\t java");
System.out.println("退格: learning\b java");
System.out.println("回车: \nlearning\r java");
/*
Linefeed:
learning java
single quote: 'learning java'
double quote: "learning java"
backslash: \learning java\
制表符: learning java
退格: learnin java
回车:
java
*/