The Hello World! the program is the most basic and first program when you dive into a new programming language. This simply prints the Hello World! on the output screen. In
Scala, a basic program consists of the following:
- object
- Main Method
- Statements or Expressions
Example:
Output:
Hello World!
Explanation:
- object Geeks: object is the keyword which is used to create the objects. Objects are the instance of a class. Here “Geeks” is the name of the object.
- def main(args: Array[String]): def is the keyword in Scala which is used to define the function and "main" is the name of Main Method. args: Array[String] are used for the command line arguments.
- println("Hello World!"): println is a method in Scala which is used to display the Output on console.
How to run a Scala Program?