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