Sometimes you need to print characters that have special meaning in Java. You do this with escape characters: a backslash followed by a letter.
The most common ones:
\ninserts a newline. The text after it appears on the next line.\tinserts a tab. This adds horizontal spacing.\\prints a literal backslash. Since\starts an escape sequence, you need of them to print one.\"prints a double quote inside a string. Without the backslash, Java thinks the string ended early.
Here's an example:
System.out.println("Line 1\nLine 2");
System.out.println("She said \"hello\"");
Output:
Line 1
Line 2
She said "hello"
If you forget the backslash before a quote, the compiler sees a string that ends too early and reports a syntax error.