Open In App

Scala Long toChar() method with example

The toChar() method is utilized to convert the specified number into character value. Here the specified number is ASCII value.

Method Definition: (Number).toChar



Return Type: It returns the converted character value.

Example 1:




// Scala program of Long toChar()
// method
  
// Creating object
object Test
{
  
    // Main method
    def main(args : Array[String])
    {
  
        // Implementing toChar method
        val res = (68).toChar
  
        // Displays output
        println(res)
    }
}

Output:



D

Example 2:




// Scala program of Long toChar()
// method
  
// Creating object
object Test
{
  
    // Main method
    def main(args : Array[String])
    {
  
        // Implementing toChar method
        val res = (82).toChar
  
        // Displays output
        println(res)
    }
}

Output:

R

Article Tags :