Scala Mutable SortedSet toString() method Last Updated : 26 Mar, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report In Scala mutable collections, SortedSet 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.mutable.SortedSet // Creating object object GfG { // Main method def main(args:Array[String]) { // Creating a SortedSet val s1 = SortedSet(1, 3, 44, 5) // Applying toString method val result = s1.toString // Display output println(result) } } Output: TreeSet(1, 3, 5, 44) Example #2: Scala // Scala program of toString() // method import scala.collection.mutable.SortedSet // Creating object object GfG { // Main method def main(args:Array[String]) { // Creating a SortedSet val s1 = SortedSet(444, 555, 777, 666, 111) // Applying toString method val result = s1.toString // Display output println(result) } } Output: TreeSet(111, 444, 555, 666, 777) Comment More infoAdvertise with us Next Article Scala Mutable SortedSet toArray() method S Shivam_k Follow Improve Article Tags : Scala Scala Scala-Method Scala mutable-sortedset Similar Reads Scala Mutable SortedSet toList() method In Scala mutable collections, 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 1 min read Scala Mutable SortedSet toSeq() method In Scala mutable collections, SortedSet 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() // met 1 min read Scala Mutable SortedSet takeRight() method In Scala mutable collections, takeRight() method is utilized to return a SortedSet consisting of last 'n' elements of the SortedSet. Method Definition: def takeRight(n: Int):SortedSet[A] Where 'n' is specifies the number of elements to select. Return Type: It returns a SortedSet consisting of last ' 1 min read Scala Mutable SortedSet tail() method In Scala mutable collections, tail() method is utilized to return a SortedSet consisting of all the elements except the first element of the SortedSet. Method Definition: def tail: SortedSet[A] Return Type: It returns a SortedSet consisting of all the elements except the first element of the SortedS 1 min read Scala Mutable SortedSet toArray() method In Scala mutable collections, 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 1 min read Scala Mutable SortedSet toMap() method In Scala mutable collections, toMap() method is utilized to return a map consisting of all the elements of the SortedSet. Method Definition: def toMap[T, U]: Map[T, U] Return Type: It returns a map consisting of all the elements of the SortedSet. Example #1: Scala // Scala program of toMap() // meth 1 min read Like