Literals and Escape Sequence

Literal

Literal: a fixed value that is written directly in code

  • stay constant throughout the program

  • Numberal literal

    • ex) 10

  • String literal

    • ex) “I am a string!”


Printing String Literal

System.out.PrintIn
System.out.Print

PrintIn

  • moves the cursor to a new line after printing


Print

  • stays on the same line after printing


Escape Sequence

Escaple Sequence: allows to include special character and actions in String literals

\"

enables to include quotation marks in a String

\n

creates a line break in the middel of a String

\t

Inserts a tab space

\\

enables to include a backslash in a String