Scala SortedSet toString() method with example Last Updated : 03 Nov, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report 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.collection.immutable.SortedSet // Creating object object GfG { // Main method def main(args:Array[String]) { // Creating a SortedSet val s1 = SortedSet(1, 2, 3, 4, 5) // Applying toString method val result = s1.toString // Display output println(result) } } Output: TreeSet(1, 2, 3, 4, 5) Example #2: Scala // Scala program of toString() // method import scala.collection.immutable.SortedSet // Creating object object GfG { // Main method def main(args:Array[String]) { // Creating a SortedSet val s1 = SortedSet(41, 12, 23, 43, 1, 72) // Applying toString method val result = s1.toString // Display output println(result) } } Output: TreeSet(1, 12, 23, 41, 43, 72) Comment More infoAdvertise with us Next Article Scala SortedSet toString() method with example G gopaldave Follow Improve Article Tags : Scala Scala-Method scala-collection Similar Reads Scala Set toString() method with example The toString() method is utilized to return a string consisting of all the elements of the set. Method Definition: def toString(): String Return Type: It returns a string consisting of all the elements of the set. Example #1: Scala // Scala program of toString() // method // Creating object object G 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 SortedSet toList() method with example The toList() method is utilized to return a list consisting of all the elements of the SortedSet. Method Definition: def toList: List[A] Return Type: It returns a list consisting of all the elements of the SortedSet. Example #1: Scala // Scala program of toList() // method import scala.collection.im 1 min read Scala SortedSet toSeq() method with example The toSeq() method is utilized to return a seq consisting of all the elements of the SortedSet. Method Definition: def toSeq: Seq[A] Return Type: It returns a seq consisting of all the elements of the SortedSet. Example #1: Scala // Scala program of toSeq() // method import scala.collection.immutabl 1 min read 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 Like