Skip to main content

Printing Variables and Values in Kotlin

1 min read Updated June 30, 2026
Share:
On this page (5sections)

Syntax

// 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 ")
    
    //Expressions 
    println("num + num Value is ${num+num} ")
}

Sample Output

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

How It Works

Here is a step-by-step walkthrough of how the Kotlin program for Printing Variables and Values in Kotlin runs, line by line:

  1. fun main(args: Array < String > ) { — defines a function used by the program.
  2. val num = 100 — declares or assigns a value the program uses.
  3. println("Print Plain String ") — writes a line of output shown in the sample output.
  4. println("num Value is $num ") — writes a line of output shown in the sample output.
  5. println("num + num Value is ${num+num} ") — writes a line of output shown in the sample output.

After running it, compare your console output with the Sample Output above. Try changing the values and re-running the program to see how the result changes — experimenting is the fastest way to understand the logic.

Frequently Asked Questions

What is Printing Variables and Values in Kotlin?
Printing Variables and Values is demonstrated in this Kotlin tutorial with a complete, runnable example and its sample output.
How do I run this Kotlin example?
Run it in IntelliJ IDEA or Android Studio, or compile from the command line with `kotlinc file.kt -include-runtime -d file.jar` and run `java -jar file.jar`.
How can I practice Printing Variables and Values?
Copy the example into IntelliJ IDEA or Android Studio, run it, then change the values or add print statements to see how the output changes.

Related Tutorials

Search tutorials