This method is same as mkString() but here a start, a separator, and an end is also added.
Method Definition: defmkString(start: String, sep: String, end: String): String
Return Type: It returns the elements of the SortedMap as a string along with a stated start, separator and an end.
Example #1:
import scala.collection.SortedMap
object GfG
{
def main(args : Array[String])
{
val m 1 = SortedMap( "geeks" - > 5 , "for" - > 3 , "cs" - > 2 )
val result = m 1 .mkString( ">>>" , "|" , "--" )
println(result)
}
}
|
Output:
>>>cs -> 2|for -> 3|geeks -> 5--
Example #2:
import scala.collection.SortedMap
object GfG
{
def main(args : Array[String])
{
val m 1 = SortedMap( "geeks" - > 5 , "for" - > 3 , "for" - > 3 )
val result = m 1 .mkString( ">>>" , "|" , "--" )
println(result)
}
}
|
Output:
>>>for -> 3|geeks -> 5--
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!
Last Updated :
04 May, 2020
Like Article
Save Article