Scala SortedMap toArray() method with example Last Updated : 02 Nov, 2019 Comments Improve Suggest changes Like Article Like Report The toArray() method is utilized to display an array from the Scala SortedMap. Method Definition: def toArray: Array[(A, B)] Return Type: It returns an array from the stated SortedMap. Example #1: Scala // Scala program of toArray() // method import scala.collection.immutable.SortedMap // Creating object object GfG { // Main method def main(args:Array[String]) { // Creating a SortedMap val m1 = SortedMap(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 import scala.collection.immutable.SortedMap // Creating object object GfG { // Main method def main(args:Array[String]) { // Creating a SortedMap val m1 = SortedMap(3 -> "geeks", 4 -> "for", 2 -> "cs") // Applying toArray method val result = m1.toArray for ( m5 <-result ) { // Display output println(m5 ) } } } Output: (2, cs) (3, geeks) (4, for) Comment More infoAdvertise with us Next Article Scala SortedMap toArray() method with example gopaldave Follow Improve Article Tags : Scala Scala Scala-Method Similar Reads Scala SortedSet toArray() method with example The toArray() is utilized to return an array consisting of all the elements of the SortedSet. Method Definition: def toArray: Array[A] Return Type: It returns an array consisting of all the elements of the SortedSet. Example #1: Scala // Scala program of toArray() // method import scala.collection.i 1 min read Scala SortedMap take() method with example The take() method is utilized to select the first 'n' elements of the SortedMap. Method Definition: def take(n: Int): SortedMap[A, B] Return Type: It returns the first 'n' elements of the SortedMap. Example #1: Scala // Scala program of take() // method import scala.collection.immutable.SortedMap // 1 min read Scala Mutable SortedMap toArray() method with example The toArray() method is utilized to display an array from the Scala SortedMap. Method Definition: def toArray: Array[(A, B)] Return Type: It returns an array from the stated SortedMap. Example #1: Scala // Scala program of toArray() // method import scala.collection.SortedMap // Creating object obje 1 min read 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 SortedMap toString() method with example The toString() method is utilized to display a string from the Scala SortedMap. Method Definition: def toString(): String Return Type: It returns a string from the stated SortedMap. Example #1: Scala // Scala program of toString() // method import scala.collection.immutable.SortedMap // Creating obj 1 min read Scala SortedMap toSeq() method with example The toSeq() method is utilized to display a sequence from the Scala SortedMap. Method Definition: def toSeq: Seq[A] Return Type: It returns a sequence from the stated SortedMap. Example #1: Scala // Scala program of toSeq() // method import scala.collection.immutable.SortedMap // Creating object obj 1 min read Scala Stack toArray() method with example In Scala Stack class, the toArray() is utilized to return an array consisting of all the elements of the stack. Method Definition: def toArray: Array[A] Return Type: It returns an array consisting of all the elements of the stack. Example #1: Scala // Scala program of toArray() // method // Import S 2 min read Scala SortedMap toSet() method with example The toSet() method is utilized to display a set from the Scala SortedMap. Method Definition: def toSet: Set[A] Return Type: It returns a set from the stated SortedMap. Example #1: Scala // Scala program of toSet() // method import scala.collection.immutable.SortedMap // Creating object object GfG { 1 min read Scala SortedMap toList() method with example The toList() method is utilized to display the elements of the SortedMap in the list. Method Definition: def toList: List[A] Return Type: It returns all the elements of the SortedMap in the list. Example #1: Scala // Scala program of toList() // method import scala.collection.immutable.SortedMap // 1 min read Like