Kotlin Output
Kotlin Output (Print Text)
In Kotlin, text or output is printed to the console using print() and println() functions.
1. println() – Print with New Line
println() prints the text and moves the cursor to the next line.
Output:
2. print() – Print without New Line
print() prints text without moving to a new line.
Output:
3. Printing Variables
4. String Templates (Recommended Way)
Use $ to print variables inside strings.
5. Printing Expressions
Use ${} to print expressions.
6. Printing Multiple Values
7. Escape Characters in Output
8. Printing Without Quotes (Numbers & Boolean)
Summary
-
print()→ prints text on same line -
println()→ prints text on new line -
$variable→ print variable value -
${expression}→ print expressions
