\t
“: a TAB point for alignment, TAB (equivalent to TAB indentation), which will cause your output to be a multiple of 4 if you output a string.”a\t
“, then, will be in the outputa
And then output3
A space if the output stringaaaa\t
, will output4
After a, print four Spaces. So if the outputaaaaa\t
? , it will output later3
A space so that the output number of characters is exactly4
Multiples.
public class ChangeChar {
public static void main(String[] args) {
System.out.println("Beijing \t Shanghai \t Guangzhou \t Shenzhen"); }}Copy the code
\n
: a newline
System.out.println("Will\nSmith");
Copy the code
\ \
: Output a\
.”\
“Represents a backslash that escapes other characters
System.out.println("\ \");
System.out.println("C:\\Windows\\System32\\cmd.exe");
Copy the code
\"
: Output a"
(double quotation marks), single quotation marks are similar
System.out.println("\" ");
Copy the code
5. \r
: represents a carriage return that returns the cursor to the beginning of the current line. If there was content in the previous line, it will be overwritten;
System.out.println("Beautiful! Hello!");
Copy the code
- When using
\r
When you press Enter, the cursor will settle to the first word, and a “hello” will overwrite the previous text
- However, in the test of IDEA, I directly replaced the front “Xi moving” with the back “hello”, which should be related to the compiler.
- When \r and \n are used together, enter and line feed, which is to output “xi moving”, and then line feed output “hello”.
System.out.println("I look beautiful, R, n Hello");
Copy the code
- Exercise: Please use an output statement to input the following graphics
System.out.println("Title, author, Price, sales, three Kingdoms, Luo Guanzhong, T120, T1000");
Copy the code