Printing Variables and Values in Kotlin


In Kotlin, Printing variable is much easy compare than other languages. Add dollar sign($) in front of any variable, print or println function prints output on the screen.

Printing Types in Kotlin

  • Plain String
  • Printing Variables
  • Expressions


// String
println("Print plan String");

// Printing Variables
println("Print Variables $variable");

// Expressions
println("Print { $variable + $variable}");

Printing Variables,Expression Kotlin Example Program

// Print Variables,Expression in Kotlin example program
// Data Output Kotlin Programs, Basic Kotlin Programs

fun main(args: Array < String > ) {
    val num = 100
    //Print Values using print
    println("Print Plain String ")
    //Printing Variables
    println("num Value is $num ")
    println("num + num Value is ${num+num} ")

Sample Output

Print Plain String 
num Value is 100 
num + num Value is 200