“Hello World!” program in Scala

Hello World..!” – Probably the first message that any developer tries to print on the console, while learning a new programming language.

Let’s write a basic Scala program to print “Hello World..!” message on the console and go through each keyword in the program.

Output:

Let’s go through each line of the program

An object called HelloWorld is defined with this statement.

 

Similar to Java, main() is the starting point of the program execution in Scala. A function is defined in Scala as mentioned above.

“def” -> specifies we are going to define a function.

“main” -> function name

“args” -> parameter name

“Array[String]” -> parameter type which is Array of Strings.

 

We are calling println() method to print the string “Hello World!” to the output. By default, the output is printed on the console as this functions calls Java “System.out.println()” internally.

 

Happy Learning :).

Please leave a reply in case of any queries.

Leave a Reply

Your email address will not be published.