Scala SortedMap mkString() method with example
Last Updated :
02 Nov, 2019
The mkString() method is utilized to represent the elements of the SortedMap as a string.
Method Definition: def mkString: String
Return Type: It returns the elements of the SortedMap as a string.
Example #1:
import scala.collection.immutable.SortedMap
object GfG
{
def main(args : Array[String])
{
val m 1 = SortedMap( "geeks" - > 5 , "for" - > 3 , "cs" - > 6 )
val result = m 1 .mkString
println(result)
}
}
|
Output:
cs -> 6for -> 3geeks -> 5
Example #2:
import scala.collection.immutable.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 -> 3geeks -> 5
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...