Skip to content
Related Articles

Related Articles

Improve Article
Scala Char toInt() method with example
  • Last Updated : 29 Oct, 2019

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 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 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



My Personal Notes arrow_drop_up
Recommended Articles
Page :