Open In App

Scala Char toChar() method with example

Last Updated : 29 Oct, 2019
Improve
Improve
Like Article
Like
Save
Share
Report

The toChar() method is utilized to return itself.

Method Definition: def toChar: Char

Return Type: It returns Char.

Example: 1#




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


Output:

A

Example: 2#




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


Output:

9


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads