Scala SortedSet toArray() method with example Last Updated : 02 Nov, 2019 Comments Improve Suggest changes Like Article Like Report 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.immutable.SortedSet // Creating object object GfG { // Main method def main(args:Array[String]) { // Creating a SortedSet val s1 = SortedSet(1, 2, 3, 4, 7) // Applying toArray method val result = s1.toArray // Display output for (elem <- result) println(elem) } } Output: 1 2 3 4 7 Example #2: Scala // Scala program of toArray() // 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 toArray method val result = s1.toArray // Display output for (elem <- result) println(elem) } } Output: 1 12 23 41 43 72 Comment More infoAdvertise with us Next Article Scala SortedSet toArray() method with example gopaldave Follow Improve Article Tags : Scala Scala Scala-Method Similar Reads 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 Scala SortedSet toMap() method with example The 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() // method import scala.collection 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 SortedSet take() method with example The take() method is utilized to return a SortedSet consisting of first 'n' elements of the SortedSet. Method Definition: def take(n: Int): SortedSet[A] Where 'n' is specifies the number of element to select. Return Type: It returns a SortedSet consisting of first 'n' elements of the SortedSet. Exam 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 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 SortedSet toBuffer() method with example The toBuffer() method is utilized to return a buffer consisting of all the elements of the SortedSet. Method Definition: def toBuffer[B >: A]: Buffer[B] Return Type: It returns a buffer consisting of all the elements of the SortedSet. Example #1: Scala // Scala program of toBuffer() // method imp 1 min read Scala SortedSet -() method with example The -() method is utilized to creates a new SortedSet with a given element removed from the SortedSet. Method Definition: def -(elem: A): SortedSet[A] Return Type: It returns a new SortedSet with a given element removed from the SortedSet. Example #1: Scala // Scala program of -() // method import s 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 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 Like