Enrollments Open for Advanced Certification Courses on Data Science, ML & AI by E&ICT Academy IIT Roorkee
Apply NowLet'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
No hints are availble for this assesment
Answer is not availble for this assesment
Note - Having trouble with the assessment engine? Follow the steps listed here
Loading comments...