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