Scala Set product() method with example Last Updated : 18 Oct, 2019 Improve Improve Like Article Like Save Share Report The product() method is utilized to find the product of all the elements of the set. Method Definition: def product: A Return Type: It returns the product of all the elements of the set. Example #1: // Scala program of product() // method // Creating object object GfG { // Main method def main(args:Array[String]) { // Creating a set val s1 = Set(1, 2, 3) // Applying product method val result = s1.product // Display output println(result) } } Output: 6 Example #2: // Scala program of product() // method // Creating object object GfG { // Main method def main(args:Array[String]) { // Creating a set val s1 = Set(1, 2, 3, 4, 5) // Applying product method val result = s1.product // Display output println(result) } } Output: 120 Like Article Suggest improvement Previous Scala Set count() method with example Next Scala Char &(x: Byte) method with example Share your thoughts in the comments Add Your Comment Please Login to comment...