Scala SortedMap max() method with example
The max() method is utilized to find the largest element of the SortedMap.
Method Definition: def max: (A, B)
Return Type: It returns the largest element of the SortedMap.
Example #1:
import scala.collection.immutable.SortedMap
object GfG
{
def main(args : Array[String])
{
val m 1 = SortedMap( "geeks" - > 5 , "for" - > 3 , "cs" - > 2 )
val result = m 1 .max
println(result)
}
}
|
Example #2:
import scala.collection.immutable.SortedMap
object GfG
{
def main(args : Array[String])
{
val m 1 = SortedMap( "geeks" - > 5 , "for" - > 3 , "geeks" - > 6 )
val result = m 1 .max
println(result)
}
}
|
Last Updated :
03 Nov, 2019
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...