Scala Char toInt() method with example
The toInt() method is utilized to convert a stated character into an integer or its ASCII value of type Int.
Method Definition: def toInt: Int
Return Type: It returns Integer or ASCII value of the corresponding character of type Int.
Example: 1#
// Scala program of toInt()// method // Creating objectobject GfG{ // Main method def main(args:Array[String]) { // Applying toInt method val result = 'A'.toInt // Displays output println(result) }} |
Output:
65
Example: 2#
// Scala program of toInt()// method // Creating objectobject GfG{ // Main method def main(args:Array[String]) { // Applying toInt method val result = '9'.toInt // Displays output println(result) }} |
Output:
57


