by @CodingExample

How to print hello world in Scala

Home » scala » How to print hello world in Scala

This example will help you to print a Hello world program in the Scala language.

object HelloWorld {
  def main(args: Array[String]): Unit = {
    println("Hello, world!")
  }
}
  1. Create a new file called HelloWorld.scala and add the above code.
  2. Now we need to compile the code by running this command.
scalac HelloWorld.scala

This above command will generate a java bytecode.

  1. Run this command to execute the generated bytecode.
scala HelloWorld