Enrollments closing soon for Post Graduate Certificate Program in Applied Data Science & AI By IIT Roorkee | 3 Seats Left
Apply NowLogin using Social Account
     Continue with GoogleLogin using your credentials
Let's write a "Hello, World!" program to learn how to compile and run a Scala code in the console prompt.
This exercise has been included to get familiar with the basic way of compiling and running the Scala code.
Later on, we will be using Jupyter notebook to do the same which is easier and faster.
Click on Console tab on the right-hand side to get the operating system prompt.
Create a directory 'scala' in your home directory and go inside it. Create a file hello_world.scala using the command "nano hello_world.scala". To achieve these tasks, run below commands on the operating system prompt.
mkdir -p scala cd scala nano hello_world.scala
object HelloWorld { def main(args: Array[String]) { println("Hello, World!") } }
scalac hello_world.scala
You can see two class files HelloWorld$.class, HelloWorld.class. These .class files are generated as bytecode which gets executed by JVM.
scala HelloWorld
Taking you to the next exercise in seconds...
Want to create exercises like this yourself? Click here.
Note - Having trouble with the assessment engine? Follow the steps listed here
Loading comments...