Scala Map toArray() method with example Last Updated : 13 Aug, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report 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[String]) { // Creating a map val m1 = Map(3 -> "geeks", 4 -> "for", 4 -> "for") // Applying toArray method val result = m1.toArray for ( m5 <-result ) { println(m5 ) } } } Output: (3,geeks) (4,for) Example #2: Scala // Scala program of toArray() // 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 toArray method val result = m1.toArray for ( m5 <-result ) { // Display output println(m5 ) } } } Output: (3,geeks) (4,for) (2,cs) Comment More infoAdvertise with us Next Article Scala Set toArray() method with example N nidhi1352singh Follow Improve Article Tags : Scala Scala Scala-Method Scala-Map Similar Reads Scala Set toArray() method with example The toArray() is utilized to return an array consisting of all the elements of the set. Method Definition: def toArray: Array[A] Return Type: It returns an array consisting of all the elements of the set. Example #1: Scala // Scala program of toArray() // method // Creating object object GfG { // Ma 1 min read Scala Iterator toArray() method with example The toArray() method belongs to the concrete value member of the class Abstract iterator. It is utilized to convert the stated collection to an array. Method Definition: def toArray: Array[A] Return Type: It returns an array from the elements of the iterator. Example #1: Scala // Scala program of to 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 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 Set map() method with example The map() method is utilized to build a new set by applying a function to all elements of this set. Method Definition: def map[B](f: (A) => B): immutable.Set[B] Return Type: It returns a new set containing all the elements after applying the given function. Example #1: Scala // Scala program of m 1 min read Scala Map toList() method with example 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(arg 1 min read Like