Scala SortedSet max() method with example
Last Updated :
02 Nov, 2019
The max() method is utilized to find the largest element of all the elements in the SortedSet.
Method Definition: def max: A
Return Type: It returns the largest of all the elements in the SortedSet.
Example #1:
import scala.collection.immutable.SortedSet
object GfG
{
def main(args : Array[String])
{
val s 1 = SortedSet( 5 , 11 , 23 , 72 , 14 )
val result = s 1 .max
println(result)
}
}
|
Example #2:
import scala.collection.immutable.SortedSet
object GfG
{
def main(args : Array[String])
{
val s 1 = SortedSet( 5 , 11 , 23 , 72 , 14 , 21 , 118 )
val result = s 1 .max
println(result)
}
}
|
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...