Scala List product() method with example
Last Updated :
26 Jul, 2019
The product() method is utilized to find the product of all the elements in the stated list.
Method Definition: def product(num: math.Numeric[B]): B
Return Type: It returns the product of all the elements in the stated list.
Example #1:
object GfG
{
def main(args : Array[String])
{
val m 1 = List( 1 , 2 , 3 , 4 , 5 )
val result = m 1 .product
println(result)
}
}
|
Example: 2#
object GfG
{
def main(args : Array[String])
{
val m 1 = List( 1 , 0 )
val result = m 1 .product
println(result)
}
}
|
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...