The 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 list.
Example #1:
object GfG
{
def main(args : Array[String])
{
val m 1 = List( 1 , 2 , 3 )
val result = m 1 .max
println(result)
}
}
|
Example #2:
object GfG
{
def main(args : Array[String])
{
val m 1 = List( 5 , 12 , 3 , 13 )
val result = m 1 .max
println(result)
}
}
|