Kotlin Output

Kotlin Output – Complete Guide
In Kotlin, output means displaying text or values on the screen (console).
Kotlin mainly uses print() and println() for output.
1. println() – Print with New Line
Prints output and moves to the next line.
Output
- Most commonly used
- Adds a new line automatically
2. print() – Print on Same Line
Prints output without a new line.
Output
3. Printing Variables
4. String Templates (Very Important)
Kotlin uses $ to print variables inside strings.
5. Expression inside Output
Use ${} for calculations or expressions.
Output
6. Printing Multiple Values
7. Printing Boolean Output
8. Printing with Escape Characters
Output
9. Raw String Output (Triple Quotes)
No escape characters needed.
- Clean multi-line output
10. Printing Objects
Output
Common Output Mistakes
Using
+instead of string templatesForgetting
${}for expressionsUsing
print()when new line is needed
Best Practices
- Use
println()for readability - Prefer string templates over
+ Use raw strings for multi-line output- Keep output clean and meaningful
Interview Questions – Kotlin Output
Q1. Difference between print() and println()?println() adds a new line, print() does not.
Q2. How to print variable inside string?
Using $variable.
Q3. How to print expression result?
Using ${expression}.
Summary
print()→ same lineprintln()→ new line$→ variable output${}→ expression output- Triple quotes → multi-line output
