Hello World Program in Scala
object HelloWorld {
def main(args: Array[String]) = {
println("Hello World!")
}
}
Scala uses a special object
for the entry point to a program,
which includes the main
method.
In Scala 3, this can be simplified as follows:
@main
def hello() = println("Hello World!")
If you compile and run this program, you will get the following output:
Hello World!
What's Next
If you are interested in learning Scala programming, then go ahead and set up a development environment.
- Next Step: Scala development environment setup
C C++ C# Clojure Crystal D Dart Erlang F# Go Haskell Java Javascript Julia Kotlin Lua Python Rust Swift Typescript