Scala Map mkString() method with a separator with example Last Updated : 26 Jul, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report This method is same as mkString() method but here a separator is also added. Method Definition: def mkString(sep: String): String Return Type: It returns the elements of the map as a string along with the separator between them. Example #1: Scala // Scala program of mkString() // method with a separator // Creating object object GfG { // Main method def main(args:Array[String]) { // Creating map val m1 = Map("geeks" -> 5, "for" -> 3, "cs" -> 2) // Applying mkString method val result = m1.mkString("/") // Displays output println(result) } } Output: geeks -> 5/for -> 3/cs -> 2 Example #2: Scala // Scala program of mkString() // method with a separator // Creating object object GfG { // Main method def main(args:Array[String]) { // Creating map val m1 = Map("geeks" -> 5, "for" -> 3, "geeks" -> 5) // Applying mkString method val result = m1.mkString("/") // Displays output println(result) } } Output: geeks -> 5/for -> 3 Comment More infoAdvertise with us Next Article Scala Set mkString() method with a separator with example N nidhi1352singh Follow Improve Article Tags : Scala Scala Scala-Method Scala-Map Similar Reads Scala List mkString() method with a separator with example The mkString() method is utilized to display all the elements of the list in a string along with a separator. Method Definition: def mkString(sep: String): String Return Type: It returns all the elements of the list in a string along with a separator. Example #1: Scala // Scala program of mkString() 1 min read Scala Set mkString() method with a separator with example The mkString() method is utilized to display all the elements of the set in a string along with a separator. Method Definition: def mkString(sep: String): String Return Type: It returns all the elements of the set in a string along with a separator. Example #1: Scala // Scala program of mkString() / 1 min read Scala Iterator mkString() method with a separator with example This method is same as mkString() method but here a separator is included. Method Definition: def mkString(sep: String): String Return Type: It returns the string representation of the stated collection with a given separator. Example #1: Scala // Scala program of mkString() // method with a separat 1 min read Scala Queue mkString() method with a separator with example The mkString() method is utilized to display all the elements of the queue in a string along with a separator. Method Definition: def mkString(sep: String): String Return Type: It returns all the elements of the queue in a string along with a separator. Example #1: Scala // Scala program of mkString 1 min read Scala Stack mkString() method with a separator with example In Scala Stack class, the mkString() method is utilized to display all the elements of the stack in a string along with a separator. Method Definition: def mkString(sep: String): String Return Type: It returns all the elements of the stack in a string along with a separator. Example #1: Scala // Sca 1 min read Scala TreeSet mkString() method with a separator with example The mkString() method is utilized to display all the elements of the TreeSet in a string along with a separator. Method Definition: def mkString(sep: String): String Return Type: It returns all the elements of the TreeSet in a string along with a separator. Example #1: Scala // Scala program of mkSt 1 min read Like