Unit 1 Lesson 12 - Debugging Strategies

Lesson summary and assignments

In order to print to the Console, use the static methods 'print()' and println() of the 'System.out' class like this. Everything between the parenthesis will be sent the Console.

System.out.print();

System.out.println();

'print()' sends its output to the console, then leaves the cursor at the end of what was just printed. This allows additional items to be printed on the same line.

'println()' sends its output to the console, then sends a "carriage return/line feed" to the console. This advances the cursor to the next line so that the next item printed will be printed on a new line.

When using a string literal in code, certain characters cannot be put directly within the string literal. In these cases, you use an 'escape sequence' or 'escape character' to encode the special character. The 'escape sequence' consists of a backslash followed by another character. A backslash within a string indicates that the next character will be a code for which character should be included in the string at that position. The escape sequences in java which can be included within a string are as follows:

Escape

sequence

Character to be inserted into string.
\t Inserts a tab
\b Inserts a backspace
\n Inserts a new line
\r Inserts a carriage return
\f Inserts a form feed
\' Inserts a single quote
\" Inserts a double quote
\\ Inserts a single backslash

Vocabulary

data type
the format of the data that can be stored in a variable
declaration
giving a name and data type to a variable
variable
a container that stores a value in memory