Scala ListSet max() method with example
In Scala ListSet, max() method is utilized to find the largest element of all the elements in the stated list.
Method Definition: def max[B >: A](implicit ord: math.Ordering[B]): A
Return Type: It returns the largest of all the elements in the stated listSet.
Example 1:
Scala
import scala.collection.immutable. _
object GfG
{
def main(args : Array[String])
{
val m 1 = ListSet( 1 , 2 , 3 )
val result = m 1 .max
println(result)
}
}
|
Example 2:
Scala
import scala.collection.immutable. _
object GfG
{
def main(args : Array[String])
{
val m 1 = ListSet( 1 , 2 , - 3 )
val result = m 1 .max
println(result)
}
}
|
Last Updated :
17 Feb, 2023
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...