Scala Char toChar() method with example
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