Please note, this is a STATIC archive of website www.w3resource.com from 19 Jul 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.
w3resource

Scala Programming: Print hello world and version of the scala language

Scala Programming Basic Exercise-1 with Solution

Write a Scala program to print "Hello, world" and version of the Scala language.

Sample Solution:

Scala Code-1:

object HelloWorld {
  def main(args: Array[String]): Unit = {
    println("Hello, world!")
    println("Scala language: "+util.Properties.versionString)
  }
}

Sample Output:

Hello, world!
Scala language: version 2.13.3

Scala Code-2:

object Hello extends App {
    println("Hello, world")
    println("Scala language: "+util.Properties.versionString)
}

Sample Output:

Hello, world
Scala language: version 2.13.3

Scala Code Editor :

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous: Scala Basic Exercises Home.
Next: Write a Scala program to compute the sum of the two given integer values. If the two values are the same, then return triples their sum.

What is the difficulty level of this exercise?