Page 37 - CA_Blue( J )_Class10
P. 37
Escape Sequence Description
\t Used to insert a horizontal tab.
\b Used to insert a backspace.
\n Used to insert a newline.
\r Used to insert a carriage return.
\f Used to insert a form feed.
\' Used to insert a single quote character.
\" Used to insert a double quote character.
\\ Used to insert a backslash character.
3.3.1 Using Escape Sequence Characters in Bluej
The escape sequence characters are used to print those characters that we cannot directly print on the terminal.
For example, if you want to print double quotes in your program output, you cannot print them without the escape
sequence character (\") because double quotes have a special meaning in Java programming. Let us learn about some
of the escape sequence characters in detail.
Printing Text with Horizontal Tab Space
The \t character is used to separate two values on the screen as output with a horizontal tab (a gap of 8 spaces)
between them. It is used mainly to print according to the format given. For example:
You will get the following output:
Printing Text in New Line
The \n character is the newline character. It is used to print the characters which are encountered after \n in the next
line. You can think like, while printing "Good Morning: \nStudents", when the Java compiler encounters 'G', it prints
'G' on the screen and when 'o', then 'o' and so on. Then, when it encounters '\n', it comes to a new line and the rest
sentence prints in the new line.
35
Values and Data Types 35

