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 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 Scala Queue +=:() method with example The +=:() method is utilized to add an element at the front of a queue. Method Definition: def +=:(elem: A): Queue.this.type Return Type: It returns the given queue with an element added at its front. Example #1: Scala // Scala program of +=:() // method // Import Queue import scala.collection.mutab 1 min read Scala Queue apply() method with example The apply() method is utilized to find the element at any given index in a queue. Method Definition: def apply(idx: Int): A Return Type: It returns the element at the given index of the queue. Example #1: Scala // Scala program of apply() // method // Import Queue import scala.collection.mutable._ / 1 min read Scala Map clone() method with example The clone() method is utilized to make a copy of the receivers object. value clone is a member of scala.collection.mutable.Map[String, Int]. Method Definition: def clone(): Map[A, B] Return Type: It returns the copy of the map used. Example #1: Scala // Scala program of clone() // method // Creating 1 min read Scala Queue map() method with example The map() method is utilized to build a new queue by applying a function to all elements of this queue. Method Definition: def map[B](f: (A) => B): Queue[B] Return Type: It returns a new queue containing all the elements after applying the given function. Example #1: Scala // Scala program of map 2 min read Scala Queue copyToArray() method with example The copyToArray() method is utilized in copying the elements of the queue to an Array. Method Definition: def copyToArray[B >: A](xs: Array[B], start: Int, len: Int): Int Parameters: xs: It denotes the array where elements are copied. start: It denotes the starting index for the copy to takes pla 2 min read Like