Create, Compile and Run the Hello World Program in Scala
Scala programs can be written in a very easy manner, follow the below two steps to create, compile and run the program.
1. Open a text editor, write the following "Hello World" program and save the file with .scala extension i.e. HelloWorld.scala
Note: The file name should be the same as the class name with extension .scala - for example, if the class name is HelloWorld then the file name should be HelloWorld.scala
Hello World Program - HelloWorld.scala
object HelloWorld {
def main(args: Array[String]) = {
println("Hello world")
}
}
2. Compile the scala file (i.e. scala program) using the command scalac HelloWorld.scala and execute the compiled byte code using the command scala HelloWorld