How to print hello world in Scala
Learn, how to print a Hello world
program in the Scala language.
- Create a new file called
HelloWorld.scala
and add the following code.
object HelloWorld {
def main(args: Array[String]): Unit = {
println("Hello, world!")
}
}
- Now, we need to compile the code by running this command.
scalac HelloWorld.scala
This above command will generate a java bytecode.
- Run this command to execute the generated bytecode.
scala HelloWorld