Scala Program to Get the First Element of Set Using the Head Property

Scala program to get the first element of Set using the head property

// Scala program to get the first element
// of Set using head property

import scala.collection.immutable._

object Sample {
  // Main method
  def main(args: Array[String]) {
    //Set of cities.
    val cities = Set("DELHI", "MUMBAI", "AGRA", "GWALIOR")

    println("First element: " + cities.head);
  }
}

Output

First element: DELHI
Share on:

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Comment