Mastering Java - Full Guide
Variables & Print Statements
Variables & Print StatementsPrinting to the Console
A print statement is used to display text to your console.
System.out.print("Hello World!");OUTPUT:
Hello World!New Line
\n will move your text to the next line.
System.out.print("Hello\nWorld!");OUTPUT:
Hello
World!Tab Space
\t will tab your text (usually adds 4 spaces).
System.out.print("Hello\tWorld!");OUTPUT:
Hello World!Difference Between print, println, and printf
Java provides three primary ways to print output to the console:
Members only
Keep reading this lesson
You've reached the end of the free preview. Unlock the rest of this lesson plus 14 more lessons in Mastering Java - Full Guide.
- Unlimited coding questions
- Unlimited access to all classroom material
- Weekly live call for questions and guidance
- 3,000 AI tutor tokens / month
- Personal SQL database (3 MB)
- Progress tracking
Cancel any time.