Scala String toString() method with example Last Updated : 29 Oct, 2019 Comments Improve Suggest changes Like Article Like Report The toString() method is utilized to return a string object itself. Method Definition: String toString() Return Type: It returns the string object. Example: 1# Scala // Scala program of toString() // method // Creating object object GfG { // Main method def main(args:Array[String]) { // Applying toString method val result = "GEEKS".toString() // Displays output println(result) } } Output: GEEKS Example: 2# Scala // Scala program of toString() // method // Creating object object GfG { // Main method def main(args:Array[String]) { // Applying toString method val result = "10".toString() // Displays output println(result) } } Output: 10 Comment More infoAdvertise with us Next Article Scala String toString() method with example N nidhi1352singh Follow Improve Article Tags : Scala Scala Scala-Method Scala-Strings Similar Reads 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 String trim() method with example The trim() method is utilized to omit the leading and trailing spaces in the stated string. Method Definition: String trim() Return Type: It returns the stated string after removing all the white spaces. Example: 1# Scala // Scala program of trim() // method // Creating object object GfG { // Main m 1 min read Scala Stack toString() method with example In Scala Stack class, the toString() method is utilized to return a string representation of the stack object. Method Definition: def toString(): String Return Type: It returns a string representation of the stack object. Example #1: Scala // Scala program of toString() // method // Import Stack imp 2 min read Scala SortedMap toString() method with example The toString() method is utilized to display a string from the Scala SortedMap. Method Definition: def toString(): String Return Type: It returns a string from the stated SortedMap. Example #1: Scala // Scala program of toString() // method import scala.collection.immutable.SortedMap // Creating obj 1 min read Scala SortedSet toString() method with example The toString() method is utilized to return a string consisting of all the elements of the SortedSet. Method Definition: def toString(): String Return Type: It returns a string consisting of all the elements of the SortedSet. Example #1: Scala // Scala program of toString() // method import scala.co 1 min read Like