Scala Queue mkString() method with example Last Updated : 29 Oct, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report The mkString() method is utilized to display all elements of the queue in a string. Method Definition: def mkString: String Return Type: It returns a string containing all the element of the queue. Example #1: Scala // Scala program of mkString() // method // Import Queue import scala.collection.mutable._ // Creating object object GfG { // Main method def main(args:Array[String]) { // Creating a queue val q1 = Queue(1, 2, 3, 4) // Print the queue println(q1) // Applying mkString method val result = q1.mkString // Display output print("Queue: " + result) } } Output: Queue(1, 2, 3, 4) Queue: 1234 Example #2: Scala // Scala program of mkString() // method // Import Queue import scala.collection.mutable._ // Creating object object GfG { // Main method def main(args:Array[String]) { // Creating a queue val q1 = Queue("Geeks", "Will", "Rule") // Print the queue println(q1) // Applying mkString method val result = q1.mkString // Display output print("Queue: " + result) } } Output: Queue(Geeks, Will, Rule) Queue: GeeksWillRule Comment More infoAdvertise with us Next Article Scala Stack mkString() method with example R rupesh_rao Follow Improve Article Tags : Scala Scala Scala-Method scala-collection Similar Reads Scala Map mkString() method with example The mkString() method is utilized to represent the elements of the map as a string. Method Definition: def mkString: String Return Type: It returns the elements of the map as a string. Example #1: Scala // Scala program of mkString() // method // Creating object object GfG { // Main method def main( 1 min read Scala Set mkString() method with example The mkString() method is utilized to display all elements of the set in a string. Method Definition: def mkString: String Return Type: It returns a string containing all the element of the set. Example #1: Scala // Scala program of mkString() // method // Creating object object GfG { // Main method 1 min read Scala List mkString() method with example The mkString() method is utilized to display all the elements of the list in a string. Method Definition: def mkString: String Return Type: It returns all the elements of the list in a string. Example #1: Scala // Scala program of mkString() // method // Creating object object GfG { // Main method d 1 min read Scala Stack mkString() method with example In Scala Stack class, the mkString() method is utilized to display all elements of the stack in a string. Method Definition: def mkString: String Return Type: It returns a string containing all the element of the stack. Example #1: Scala // Scala program of mkString() // method // Import Stack impor 1 min read Scala TreeSet mkString() method with example The mkString() method is utilized to display all elements of the TreeSet in a string. Method Definition: def mkString: String Return Type: It returns a string containing all the element of the TreeSet. Example #1: Scala // Scala program of mkString() // method // Import TreeSet import scala.collecti 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 Like