Open In App

Scala Char toString() method with example

Improve
Improve
Like Article
Like
Save
Share
Report

The toString() method is utilized to convert a stated character into String.

Method Definition: def toString: String

Return Type: It returns the String representation of the stated character.

Example: 1#




// Scala program of toString()
// method
  
// Creating object
object GfG
  
    // Main method
    def main(args:Array[String])
    {
      
        // Applying toString method
        val result = 'B'.toString
          
        // Displays output
        println(result)
      
    }


Output:

B

Example: 2#




// Scala program of toString()
// method
  
// Creating object
object GfG
  
    // Main method
    def main(args:Array[String])
    {
      
        // Applying toString method
        val result = 'b'.toString
          
        // Displays output
        println(result)
          
    }


Output:

b


Last Updated : 29 Oct, 2019
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads