Scala Basics
Run a small program with an entry point.
Scala
object Main {
def main(args: Array[String]): Unit = {
val name = "Ada"
println(s"Hello, $name")
}
}Output
Hello, Ada
Explanation
The main method is called when the program starts. val binds an immutable value, and println writes it.
Explore the dry run
Guided walkthroughReady
1
object Main {2
def main(args: Array[String]): Unit = {3
val name = "Ada"4
println(s"Hello, $name")5
}6
}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 |
|---|---|---|---|
| Create immutable name when main runs. | name = "Ada" | — | |
| Interpolate name into the string and print. | name = "Ada" | Hello, Ada |