How To Write A Hello World Program in Scala
Since the
Scala plugin is installed, we can create a Scala Project from the
“File->New” menu option. If the option Scala Project does not
show up, select the “Other” option, then scroll down to “Scala
Wizards” and select “Scala Project”.
Create a
new package inside the “source” folder. Right click on the new
package and select “New->Scala Object”. Provide a name of the
Object and click Finish. A Scala object is created inside the package
and we can write code inside the object. Let us put a simple main
function printing the text “Hello World”. The code snippet is
shown below:
| object HelloWorld { def main(args: Array[String]){ println("Hello World!") } } |
Doing a
right click and selecting “Run As -> Scala Application” will
run the program. It will print the text in the console as shown
below:
|
Hello World!
|
No comments:
Post a Comment