Scala Mutable SortedMap toArray() method with example Last Updated : 04 May, 2020 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.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.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 Mutable SortedMap toArray() method with example S Shivam_k Follow Improve Article Tags : Python Scala Scala Mutable-collections Scala Mutable-SortedMap Practice Tags : python Similar Reads Scala Mutable 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.SortedMap // Creating 1 min read Scala Mutable SortedMap tail() method with example The tail() method is utilized to display all the elements of the SortedMap except the first one. Method Definition: def tail: SortedMap[A, B] Return Type: It returns all the elements of the stated SortedMap except the first one. Example #1: Scala // Scala program of tail() // method import scala.col 1 min read Scala Mutable 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.SortedMap // Creating object object GfG { 1 min read Scala Mutable 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.SortedMap // Creating object object GfG { // Main me 1 min read Scala 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.immutable.SortedMap // Creating o 1 min read Like