Scala Queue max() method with example Last Updated : 29 Oct, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report The max() method is utilized to return the largest method of the queue. Method Definition: def max: A Return Type: It returns the largest element of the queue. Example #1: Scala // Scala program of max() // 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, 3, 2, 7, 6, 5) // Print the queue println(q1) // Applying max method val result = q1.max // Display output print("The largest element of the queue: " + result) } } Output: Queue(1, 3, 2, 7, 6, 5) The largest element of the queue: 7 Example #2: Scala // Scala program of max() // method // Import Queue import scala.collection.mutable._ // Creating object object GfG { // Main method def main(args:Array[String]) { // Creating a queue val q1 = Queue(5, 11, 23, 72, 14, 21, 118) // Print the queue println(q1) // Applying max method val result = q1.max // Display output print("The largest element of the queue: " + result) } } Output: Queue(5, 11, 23, 72, 14, 21, 118) The largest element of the queue: 118 Comment More infoAdvertise with us Next Article Scala Queue max() method with example R rupesh_rao Follow Improve Article Tags : Scala Scala Scala-Method scala-collection Similar Reads Scala Queue last() method with example The last() method is utilized to return the last element of the queue. Method Definition: def last: A Return Type: It returns the last element of the queue. Example #1: Scala // Scala program of last() // method // Import Queue import scala.collection.mutable._ // Creating object object GfG { // Mai 1 min read Scala Queue min() method with example The min() method is utilized to return the smallest element of the queue. Method Definition: def min: A Return Type: It returns the smallest element of the queue. Example #1: Scala // Scala program of min() // method // Import Queue import scala.collection.mutable._ // Creating object object GfG { / 1 min read Scala Set max() method with example The max() method is utilized to find the largest element of all the elements in the set. Method Definition: def max: A Return Type: It returns the largest of all the elements in the set. Example #1: Scala // Scala program of max() // method // Creating object object GfG { // Main method def main(arg 1 min read Scala Map max() method with example The max() method is utilized to find the largest element of the map. Method Definition: def max: (A, B) Return Type: It returns the largest element of the map. Example #1: Scala // Scala program of max() // method // Creating object object GfG { // Main method def main(args:Array[String]) { // Creat 1 min read Scala Int max() method with example The max() method is utilized to return the maximum value of the two specified int numbers. Method Definition: (First_Number).max(Second_Number) Return Type: It returns true the maximum value of the two specified int numbers. Example #1: Scala // Scala program of Int max() // method // Creating objec 1 min read Like