Scala SortedSet mkString() method with a separator with example
Last Updated :
03 Nov, 2019
The mkString() method is utilized to display all the elements of the SortedSet in a string along with a separator.
Method Definition: def mkString(sep: String): String
Return Type: It returns all the elements of the SortedSet in a string along with a separator.
Example #1:
import scala.collection.immutable.SortedSet
object GfG
{
def main(args : Array[String])
{
val s 1 = SortedSet( 1 , 2 , 3 , 4 )
val result = s 1 .mkString( ", " )
println(result)
}
}
|
Example #2:
import scala.collection.immutable.SortedSet
object GfG
{
def main(args : Array[String])
{
val s 1 = SortedSet( "Geeks" , "Will" , "Rule" )
val result = s 1 .mkString( " " )
println(result)
}
}
|
Share your thoughts in the comments
Please Login to comment...