Related Articles

Related Articles

Scala String toString() method with example
  • Last Updated : 29 Oct, 2019

The toString() method is utilized to return a string object itself.

Method Definition: String toString()

Return Type: It returns the string object.

Example: 1#

filter_none

edit
close

play_arrow

link
brightness_4
code

// 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)
      
    }

chevron_right


Output:

GEEKS

Example: 2#

filter_none

edit
close

play_arrow

link
brightness_4
code

// 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)
          
    }

chevron_right


Output:

10



My Personal Notes arrow_drop_up
Recommended Articles
Page :