Console output and comments
What you will learn
Console output lets a program communicate through text. System.out.print writes without appending a line separator, while System.out.println appends one. Comments explain the code to readers and do not execute.
public class Main { public static void main(String[] args) { System.out.print("Order: "); System.out.println("ready"); }}Expected output:
Order: readyThe second operation continues on the same line and then ends it.
How it works
Use double quotes for string text. A // comment extends to the end of the line, and /* ... */ encloses a block comment. Place comments near the reason for an instruction rather than repeating the instruction itself. Output is a useful first way to inspect program behavior.
public class Main { public static void main(String[] args) { // Subtract books already borrowed. System.out.println(20 - 6); /* End of stock report. */ }}Expected output:
14Only the executable print statement produces output.
Common mistakes
Do not put a needed statement after // on the same line. It becomes part of the comment. Use println if separate output lines are intended.
Try it yourself
Print Room: B12 using two calls, then print a second line showing available seats.
These are local Java practice tasks, not automatically graded ByteMind exercises. Use a patched JDK; no network or third-party dependency is needed.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Console output and comments — knowledge check
Check your understanding of console output and comments.
Which call does not append a line separator?
What does a line starting with // do?