Scala SortedMap toString() method with example Last Updated : 02 Nov, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report 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 object object GfG { // Main method def main(args:Array[String]) { // Creating a SortedMap val m1 = SortedMap(3 -> "geeks", 4 -> "for", 4 -> "for") // Applying toString method val result = m1.toString // Displays output println(result) } } Output: Map(3 -> geeks, 4 -> for) Example #2: Scala // Scala program of toString() // 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 toString method val result = m1.toString // Displays output println(result) } } Output: Map(2 -> cs, 3 -> geeks, 4 -> for) Comment More infoAdvertise with us Next Article Scala SortedMap toString() method with example G gopaldave Follow Improve Article Tags : Scala Scala Scala-Method Similar Reads 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 SortedSet toString() method with example The toString() method is utilized to return a string consisting of all the elements of the SortedSet. Method Definition: def toString(): String Return Type: It returns a string consisting of all the elements of the SortedSet. Example #1: Scala // Scala program of toString() // method import scala.co 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 Scala Mutable 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.SortedMap // Creating object object 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 Like