Scala List size() method with example Last Updated : 26 Jul, 2019 Comments Improve Suggest changes Like Article Like Report The size() method is utilized to find the number of elements in the stated list. Method Definition: def size(): Int Return Type: It returns the number of elements in the stated list. Example #1: Scala // Scala program of size() // method // Creating object object GfG { // Main method def main(args:Array[String]) { // Creating a list val m1 = List(1, 2, 3, 4, 5) // Applying size method val result = m1.size // Displays output println(result) } } Output: 5 Example #2: Scala // Scala program of size() // method // Creating object object GfG { // Main method def main(args:Array[String]) { // Creating a list val m1 = List(1, 0) // Applying size method val result = m1.size // Displays output println(result) } } Output: 2 Comment More infoAdvertise with us Next Article Scala List size() method with example N nidhi1352singh Follow Improve Article Tags : Scala Scala Scala-Method Scala-list Similar Reads Scala ListSet size() method with example In Scala ListSet, size() method is utilized to find the number of elements of the stated listSet. Method Definition: def size(): Int Return Type: It returns the number of elements in the stated listSet. Example 1: Scala // Scala program of size() // method import scala.collection.immutable._ // Crea 1 min read Scala List take() method with example The take() method belongs to the value member of the class List. It is utilized to take the first n elements from the list. Method Definition: deftake(n: Int): List[A] Where, n is the number of elements to be taken from the list. Return Type:It returns a list containing only the first n elements fro 1 min read Scala Map size() method with example The size() is utilized to find the number of key-value pairs in the stated map. Method Definition: def size: Int Return Type: It returns the number of elements in the map. Example #1: Scala // Scala program of size() // method // Creating object object GfG { // Main method def main(args:Array[String 1 min read Scala Iterator size() method with example The size() method belongs to the concrete value members of the class Abstract Iterator. It is defined in the classes IterableOnceOps. It is utilized to find the size of the stated collection. It will not terminate for the infinite sized collection. Method Definition : def size: Int Return Type :It r 1 min read Scala Set size() method with example The size() method is utilized to find the number of elements in the set. Method Definition: def size: Int Return Type: It returns the number of elements in the set. Example #1: Scala // Scala program of size() // method // Creating object object GfG { // Main method def main(args:Array[String]) { // 1 min read Like