Scala Map toList() method with example Last Updated : 26 Jul, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report The toList() method is utilized to display the elements of the map in the list. Method Definition: def toList: List[A] Return Type: It returns all the elements of the map in the list. Example #1: Scala // Scala program of toList() // method // Creating object object GfG { // Main method def main(args:Array[String]) { // Creating a map val m1 = Map(3 -> "geeks", 4 -> "for", 2 -> "cs") // Applying toList method val result = m1.toList // Displays output println(result) } } Output: List((3, geeks), (4, for), (2, cs)) Example #2: Scala // Scala program of toList() // method // Creating object object GfG { // Main method def main(args:Array[String]) { // Creating a map val m1 = Map(3 -> "geeks", 4 -> "for", 4 -> "for") // Applying toList method val result = m1.toList // Displays output println(result) } } Output: List((3, geeks), (4, for)) Comment More infoAdvertise with us Next Article Scala Map toString() method with example N nidhi1352singh Follow Improve Article Tags : Scala Scala Scala-Method Scala-Map Similar Reads Scala Map toSet() method with example The toSet() method is utilized to display a set from the Scala map. Method Definition: def toSet: Set[A] Return Type: It returns a set from the stated map. Example #1: Scala // Scala program of toSet() // method // Creating object object GfG { // Main method def main(args:Array[String]) { // Creatin 1 min read Scala Map toSeq() method with example The toSeq() method is utilized to display a sequence from the Scala map. Method Definition: def toSeq: Seq[A] Return Type: It returns a sequence from the stated map. Example #1: Scala // Scala program of toSeq() // method // Creating object object GfG { // Main method def main(args:Array[String]) { 1 min read Scala Map toString() method with example The toString() method is utilized to display a string from the Scala map. Method Definition: def toString(): String Return Type: It returns a string from the stated map. Example #1: Scala // Scala program of toString() // method // Creating object object GfG { // Main method def main(args:Array[Stri 1 min read Scala Set toList() method with example The toList() method is utilized to return a list consisting of all the elements of the set. Method Definition: def toList: List[A] Return Type: It returns a list consisting of all the elements of the set. Example #1: Scala // Scala program of toList() // method // Creating object object GfG { // Mai 1 min read Scala Iterator toList() method with example The toList() method belongs to the concrete value members of the AbstractIterable class and is defined in the TraversableOnce and GenTraversableOnce classes. It converts a traversable or iterator to a list but it doesn't terminates for infinite-sized collections. Method Definition: def toList: List[ 1 min read Scala Map toArray() method with example The toArray() method is utilized to display an array from the Scala map. Method Definition: def toArray: Array[(A, B)] Return Type: It returns an array from the stated map. Example #1: Scala // Scala program of toArray() // method // Creating object object GfG { // Main method def main(args:Array[St 1 min read Like