Scala SortedSet last() method with example
Last Updated :
02 Nov, 2019
The 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.immutable.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.immutable.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...