Printing Multiple Values

2 min read ·

Java allows you to print multiple values either in a single output statement or across multiple lines. This helps in formatting output clearly and displaying related data together.

Printing Multiple Values in One Statement

You can print multiple values in one statement by using string concatenation.
Text and variables are combined and printed in one line.

Printing Multiple Variables Together

Different data types can be printed together in the same statement.
Each value is separated by a space for readability.

Printing Values Across Multiple Lines

To print values on separate lines, use multiple println statements.
Each value appears on a new line.

Mixing Single Line and Multiple Line Output

You can mix print and println to control formatting.
This gives more control over how the output looks.

Printing Values with Labels

Labels make output easier to understand.

Common Mistakes While Printing Multiple Values

Forgetting spaces between values Missing plus operator between values Expecting automatic spacing
Caution

Java does not add spaces automatically. You must include them explicitly.


Why Printing Multiple Values Matters

Printing multiple values helps you: Display related data clearly Improve output readability Debug programs efficiently
Goal Achieved

You can now print multiple values in one statement and across multiple lines in Java.