Beginner 5 min readKotlin 2.0

Kotlin Output โ€” println, print, and String Formatting

Kotlin provides println() and print() for console output. println adds a newline; print does not. String templates make formatting easy.

What You Will Learn

  • Difference between println and print
  • Printing variables with string templates
  • Printing numbers and expressions
  • Printing on the same line

println vs print

println() prints text and moves to the next line. print() prints text and stays on the same line.

println vs print

kotlin
fun main() {
    println("Line 1")
    println("Line 2")
    print("No newline ")
    print("Same line")
    println()
    println("New line after empty println")
}
Output
Line 1 Line 2 No newline Same line New line after empty println

println() adds \n after each call. print() does not. println() with no argument prints just a newline.

Beginner Tip: You can print any value with println โ€” not just strings. println(42) and println(true) both work.

Printing Different Types

Kotlin automatically converts values to strings when you pass them to println.

Printing Numbers, Booleans, Null

kotlin
fun main() {
    println(42)
    println(3.14)
    println(true)
    println(null)
    println(1 + 2)
}
Output
42 3.14 true null 3

println calls .toString() on its argument. Arithmetic expressions are evaluated before printing. null prints the text "null".

String Templates in Output

Instead of concatenation, Kotlin uses string templates. Use $ to embed a variable or ${} for expressions.

String Templates

kotlin
fun main() {
    val name = "Kotlin"
    val version = 2.0
    println("Language: $name")
    println("Version: $version")
    println("Name has ${name.length} characters")
    println("1 + 1 = ${1 + 1}")
}
Output
Language: Kotlin Version: 2.0 Name has 6 characters 1 + 1 = 2

$name inserts the value directly. ${name.length} evaluates an expression and inserts the result. Anything inside {} is evaluated as a Kotlin expression.

Practice Exercise

Exercisepredict output

What does this print? val x = 5 val y = 3 println("$x + $y = ${x + y}")

Quick Quiz

Quick Quiz

What is the difference between print() and println()?

Frequently Asked Questions

Related Tutorials

Last updated: 2026-05-01Kotlin 2.0

Written by KotlinGuide Editorial Team ยท Reviewed by KotlinGuide Technical Review