Scala Set toList() method with example Last Updated : 18 Oct, 2019 Comments Improve Suggest changes Like Article Like Report The toList() method is utilized to return a list consisting of all the elements of the set. Method Definition: def toList: List[A] Return Type: It returns a list consisting of all the elements of the set. Example #1: Scala // Scala program of toList() // method // Creating object object GfG { // Main method def main(args:Array[String]) { // Creating a set val s1 = Set(1, 2, 3, 4, 5) // Applying toList method val result = s1.toList // Display output for (elem <- result) println(elem) } } Output: 5 1 2 3 4 Example #2: Scala // Scala program of toList() // method // Creating object object GfG { // Main method def main(args:Array[String]) { // Creating a set val s1 = Set(41, 12, 23, 43, 1, 72) // Applying toList method val result = s1.toList // Display output for (elem <- result) println(elem) } } Output: 1 41 12 72 43 23 Comment More infoAdvertise with us Next Article Scala Stack toList() method with example R rupesh_rao Follow Improve Article Tags : Scala Scala Scala-Method scala-collection Scala-Set +1 More Similar Reads Scala Stack toList() method with example In Scala Stack class, the toList() method is utilized to return a list consisting of all the elements of the stack. Method Definition: def toList: List[A] Return Type: It returns a list consisting of all the elements of the stack. Example #1: Scala // Scala program of toList() // method // Import St 2 min read Scala Set toSeq() method with example The toSeq() method is utilized to return a seq consisting of all the elements of the set. Method Definition: def toSeq: Seq[A] Return Type: It returns a seq consisting of all the elements of the set. Example #1: Scala // Scala program of toSeq() // method // Creating object object GfG { // Main meth 1 min read Scala SortedSet toList() method with example The toList() method is utilized to return a list consisting of all the elements of the SortedSet. Method Definition: def toList: List[A] Return Type: It returns a list consisting of all the elements of the SortedSet. Example #1: Scala // Scala program of toList() // method import scala.collection.im 1 min read Scala Set toString() method with example The toString() method is utilized to return a string consisting of all the elements of the set. Method Definition: def toString(): String Return Type: It returns a string consisting of all the elements of the set. Example #1: Scala // Scala program of toString() // method // Creating object object G 1 min read Scala SortedMap toList() method with example The toList() method is utilized to display the elements of the SortedMap in the list. Method Definition: def toList: List[A] Return Type: It returns all the elements of the SortedMap in the list. Example #1: Scala // Scala program of toList() // method import scala.collection.immutable.SortedMap // 1 min read Scala Set toMap() method with example The toMap() method is utilized to return a map consisting of all the elements of the set. Method Definition: def toMap[T, U]: Map[T, U] Return Type: It returns a map consisting of all the elements of the set. Example #1: Scala // Scala program of toMap() // method // Creating object object GfG { // 1 min read Like