Learning Scala

Pankaj Patil
Aug 12, 2021

--

Hello, World

Here is the sample source code for the scala “Hello World” program.

object Hello {
def main(args: Array[String]) = {
println("Hello, world")
}
}

Using a text editor, save that source code in a file named Hello.scala. After saving it, run this scalac command at your command line prompt to compile it:

$ scalac Hello.scala

scalac is just like javac, and that command creates two new files:

  • Hello$.class
  • Hello.class

These are the same types of “.class” bytecode files you create with javac, and they’re ready to work with the JVM.

Now you can run the Hello application with the scala command:

$ scala Hello

--

--

Pankaj Patil

Software Engineer | Blogger | Reader | Writer| Political and Social Activist