Scala Map toString() method with example Last Updated : 29 Jul, 2019 Comments Improve Suggest changes Like Article Like Report The toString() method is utilized to display a string from the Scala map. Method Definition: def toString(): String Return Type: It returns a string from the stated map. Example #1: Scala // Scala program of toString() // method // Creating object object GfG { // Main method def main(args:Array[String]) { // Creating a map val m1 = Map(3 -> "geeks", 4 -> "for", 4 -> "for") // Applying toString method val result = m1.toString // Displays output println(result) } } Output: Map(3 -> geeks, 4 -> for) Example #2: Scala // Scala program of toString() // method // Creating object object GfG { // Main method def main(args:Array[String]) { // Creating a map val m1 = Map(3 -> "geeks", 4 -> "for", 2 -> "cs") // Applying toString method val result = m1.toString // Displays output println(result) } } Output: Map(3 -> geeks, 4 -> for, 2 -> cs) Comment More infoAdvertise with us Next Article Scala Float toString() method with example N nidhi1352singh Follow Improve Article Tags : Scala Scala Scala-Method Scala-Map Similar Reads Scala Map toSet() method with example The toSet() method is utilized to display a set from the Scala map. Method Definition: def toSet: Set[A] Return Type: It returns a set from the stated map. Example #1: Scala // Scala program of toSet() // method // Creating object object GfG { // Main method def main(args:Array[String]) { // Creatin 1 min read Scala Int toString() method with example The toString() method is utilized to return the string representation of the specified value. Method Definition: def toString(): String Return Type: It returns the string representation of the specified value. Example #1: Scala // Scala program of Int toString() // method // Creating object object G 1 min read Scala Float toString() method with example The toString() method is utilized to convert the specified number into string data type value. Method Definition: (Number).toString Return Type: It returns the converted String datatype value. Example #1: Scala // Scala program of Float toString() // method // Creating object object GfG { // Main me 1 min read Scala Map toList() method with example The toList() method is utilized to display the elements of the map in the list. Method Definition: def toList: List[A] Return Type: It returns all the elements of the map in the list. Example #1: Scala // Scala program of toList() // method // Creating object object GfG { // Main method def main(arg 1 min read Scala Map toSeq() method with example The toSeq() method is utilized to display a sequence from the Scala map. Method Definition: def toSeq: Seq[A] Return Type: It returns a sequence from the stated map. Example #1: Scala // Scala program of toSeq() // method // Creating object object GfG { // Main method def main(args:Array[String]) { 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 Like