Scala Mutable SortedSet last() method
Last Updated :
26 Mar, 2020
In Scala mutable collections, last() method is utilized to return the last element of the SortedSet.
Method Definition: def last: A
Return Type: It returns the last element of the SortedSet.
Example #1:
import scala.collection.mutable.SortedSet
object GfG
{
def main(args : Array[String])
{
val s 1 = SortedSet( 1 , 2 , 3 , 4 )
val result = s 1 .last
println(result)
}
}
|
Example #2:
import scala.collection.mutable.SortedSet
object GfG
{
def main(args : Array[String])
{
val s 1 = SortedSet( "geeks" , "for" , "geeks" , "classes" )
val result = s 1 .last
println(result)
}
}
|
Share your thoughts in the comments
Please Login to comment...