Scala Mutable SortedSet toArray() method
Last Updated :
26 Mar, 2020
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:
import scala.collection.mutable.SortedSet
object GfG
{
def main(args : Array[String])
{
val s 1 = SortedSet( 22 , 3 , 44 , 77 )
val result = s 1 .toArray
for (elem < - result)
println(elem)
}
}
|
Example #2:
import scala.collection.mutable.SortedSet
object GfG
{
def main(args : Array[String])
{
val s 1 = SortedSet( 443 , 451 , 772 )
val result = s 1 .toArray
for (elem < - result)
println(elem)
}
}
|
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...