Scala Mutable SortedMap mkString() method with a start, a separator and an end with example
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--
Last Updated :
04 May, 2020
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...