Scala Queue clone() method with example Last Updated : 18 Oct, 2019 Comments Improve Suggest changes Like Article Like Report The clone() method is used to create a copy of the given queue. Method Definition: defclone(): Queue[A] Return Type: It return a new queue which is a copy of the given queue. Example #1: Scala // Scala program of clone() // method // Import Queue import scala.collection.mutable._ // Creating object object GfG { // Main method def main(args:Array[String]) { // Creating a queue val q1 = Queue(10, 11, 12, 13, 14) // Print the queue println(q1) // Applying clone() method val q2 = q1.clone() // Display output print("Clone of the queue: " + q2) } } Output: Queue(10, 11, 12, 13, 14) Clone of the queue: Queue(10, 11, 12, 13, 14) Example #2: Scala // Scala program of clone() // 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", "for", "geeks") // Print the queue println(q1) // Applying clone() method val q2 = q1.clone() // Display output print("Clone of the queue: " + q2) } } Output: Queue(geeks, for, geeks) Clone of the queue: Queue(geeks, for, geeks) Comment More infoAdvertise with us Next Article Scala Queue clone() method with example R rupesh_rao Follow Improve Article Tags : Scala Scala Scala-Method scala-collection Similar Reads Scala Queue ++=() method with example The ++=() method is utilized to add element of a queue at the back of another queue. Method Definition: def ++=(xs: IterableOnce[A]): Queue.this.type Return Type: It returns the given queue with elements of another queue added at its end. Example #1: Scala // Scala program of ++=() // method // Impo 1 min read Scala Queue ++:() method with example The ++:() method is utilized to return a new queue with all the elements of the queue appended at the front of another queue. Method Definition: def ++:[B >: A](prefix: IterableOnce[B]): Queue[B] Return Type: It returns a new queue with all the elements of the queue appended at the front of anoth 1 min read Scala Queue :+() method with example The :+() method is utilized to return a new queue with an element added at the back of the given queue. Method Definition: def:+[B >: A](elem: B): Queue[B] Return Type: It returns a new queue with an element added at the back of the given queue. Example #1: Scala // Scala program of :+() // metho 1 min read Scala Queue ++() method with example The ++() method is utilized to return a new queue with all the elements of the queue appended at the back of another queue. Method Definition: def ++[B >: A](suffix: IterableOnce[B]): Queue[B] Return Type: It return a new queue with all the elements of the queue appended at the back of another qu 1 min read Scala Queue +=() method with example The +=() method is utilized to add an element at the back of a given queue. Method Definition: def +=(elem: A): Queue.this.type Return Type: It returns the given queue with an element added at its back. Example #1: Scala // Scala program of +=() // method // Import Queue import scala.collection.muta 1 min read Like