Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Hello World in Scala

object HelloWorld {
    def main(args:Array[String]) {
        println("Hello World!")
    }
}

Run Hello World in the REPL

$ scala
scala> :load Hello.scala
scala> Hello.main(null)
scala> Hello.main(Array())
$ scalac  HelloWorld.scala
$ scala   HelloWorld
Hello World!
object HelloName {
    def main(args:Array[String]) {
        val name:String = args(0)
        println("Hello " + name + "!")
    }
}