Open In App

Scala Char toInt() method with example

Last Updated : 29 Oct, 2019
Comments
Improve
Suggest changes
Like Article
Like
Report
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
// Scala program of toInt()
// method

// Creating object
object GfG
{ 

    // Main method
    def main(args:Array[String])
    {
    
        // Applying toInt method
        val result = 'A'.toInt
        
        // Displays output
        println(result)
    
    }
} 
Output:
65
Example: 2# Scala
// Scala program of toInt()
// method

// Creating object
object GfG
{ 

    // Main method
    def main(args:Array[String])
    {
    
        // Applying toInt method
        val result = '9'.toInt
        
        // Displays output
        println(result)
    
    }
} 
Output:
57

Next Article
Article Tags :

Similar Reads