Kotlin Basics
Use values and string templates.
Kotlin
fun main() {
val name = "Ada"
println("Hello, $name")
}Output
Hello, Ada
Explanation
val creates a read-only reference. main is the program entry point. A string template inserts the current value into text.
Explore the dry run
Guided walkthroughReady
1
fun main() {2
val name = "Ada"3
println("Hello, $name")4
}Follow the example
Start to inspect the source, values, and output. These prepared steps explain the published sample; grouped loop steps describe multiple iterations.
View the complete dry-run table
| Step / line | What happens | State after step | Output so far |
|---|---|---|---|
| Bind Ada to a read-only name. | name = "Ada" | — | |
| Insert name into the string template and print. | name = "Ada" | Hello, Ada |