

This article contains Scala Hello World Example with details explanation of each elements.
NOTE: Make sure that your operating system PATH variable contains SCALA_HOME path. To make sure,
Go To console & Type : scala
Welcome to Scala 2.12.4 (Java HotSpot(TM) 64-Bit Server VM, Java 9.0.1). Type in expressions for evaluation. Or try :help.
Table of Contents
HelloWorld.scala
object HelloWorld {
def main(args: Array[String]): Unit = {
println("Scala Hello World Example")
}
}object: object is used to create singleton class, scala does not support static keyword
def : function or definition
main : method name
args : Array[String] means array of String and variable name is args
Unit : Function is return nothing (void)
Compile scala code:
scalac HelloWorld.scala
scalac is scala compiler. It will generate HelloWorld.class file in current working directory.
Run scala code:
scala HelloWorld
Output:
Scala Hello World Example
References
Was this post helpful?
Let us know if you liked the post. That’s the only way we can improve.
