Scala Mutable SortedSet head() method
Last Updated :
26 Mar, 2020
In Scala mutable collections, SortedSet head() method is utilized to display the first element of the SortedSet.
Method Definition: def head: A
Return Type: It returns the first element of the SortedSet.
Example #1:
import scala.collection.mutable.SortedSet
object GfG
{
def main(args : Array[String])
{
val s 1 = SortedSet( 12 , 15 , 14 , 13 )
val result = s 1 .head
println(result)
}
}
|
Example #2:
import scala.collection.mutable.SortedSet
object GfG
{
def main(args : Array[String])
{
val s 1 = SortedSet( 6 , 7 , 5 , 4 , 1 )
val result = s 1 .head
println(result)
}
}
|
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...