Special characters

A character preceded by a backslash () is an escape sequence and has special meaning to the compiler. The following table shows the Java escape sequences. Note: Each escape sequence represents one character entity.

Escape Sequence Description
\t Insert a tab in the text at this point.
\b Insert a backspace in the text at this point.
\n Insert a newline in the text at this point.
\r Insert a carriage return in the text at this point.
\f Insert a formfeed in the text at this point.
\' Insert a single quote character in the text at this point.
\" Insert a double quote character in the text at this point.
\ Insert a backslash character in the text at this point.

Write a Java program to print a box using asterisks.

********
*      *
*      *
*      *
*      *
********

What does the following line of code print?

System.out.printf("%s\n%s\n%s\n","@","@@","@@@");

Write a Java program to print the following columns of values. Use \t for the tabs between the columns.

Cost      Quantity   Total
$1,000.00   4       $4,000.00
$   50.00   8         $400.00
______________________________
TOTAL:      12      $4,400.00

Write a Java program to print the escape sequences table below to the console.

\t    Insert a tab in the text.
\n    Insert a newline in the text.
\r    Insert a carriage return.
\'    Insert a single quote character.
\"    Insert a double quote character.
\\    Insert a backslash character.

results matching ""

    No results matching ""