1、未解决的问题:有点奇怪的是:回退字符,并没有出现大家说的问题,就是出现回退字符的后面字符会吃掉前面的一个字符。不知道是为什么。
2、测试code:
public class Main{
public static void main(String[] args) {
// Scanner in = new Scanner(System.in);
//单引号
String str1="I\'love\'working!";
//双引号
String str2="I\"love\"working!";
//反斜线
String str3="I\\love\\working!";
//制表符
String str4="I\tlove\tworking!";
//回退符
String str5="I \blove \bworking!";
//回车符:将当前位置移到本行开始:故会覆盖\r之前输出的字符
String str6="I\rlove\rworking!";
//走纸符
String str7="I\flove\fworking!";
//换行符:将当前位置移到下一行开始
String str8="I\nlove\nworking!";
//输出:
System.out.println("单引号--------------");
System.out.println(str1);
System.out.println();
System.out.println("双引号--------------");
System.out.println(str2);
System.out.println();
System.out.println("反斜线--------------");
System.out.println(str3);
System.out.println();
System.out.println("制表符--------------");
System.out.println(str4);
System.out.println();
System.out.println("回退符--------------");
System.out.println(str5);
System.out.println();
System.out.println("回车符--------------");
System.out.println(str6);
System.out.println();
System.out.println("走纸符--------------");
System.out.println(str7);
System.out.println();
System.out.println("换行符--------------");
System.out.println(str8);
System.out.println();
}
}
输出结果:
单引号--------------
I'love'working!
双引号--------------
I"love"working!
反斜线--------------
I\love\working!
制表符--------------
I love working!
回退符--------------
Iloveworking!
回车符--------------
working!
走纸符--------------
I love working!
换行符--------------
I
love
working!