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:
import scala.collection.mutable.SortedSet
object GfG
{
def main(args : Array[String])
{
val s 1 = SortedSet( 1 , 3 , 44 , 5 )
val result = s 1 .toString
println(result)
}
}
|
Output:
TreeSet(1, 3, 5, 44)
Example #2:
import scala.collection.mutable.SortedSet
object GfG
{
def main(args : Array[String])
{
val s 1 = SortedSet( 444 , 555 , 777 , 666 , 111 )
val result = s 1 .toString
println(result)
}
}
|
Output:
TreeSet(111, 444, 555, 666, 777)
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!