Open In App

Scala Int toInt() method with example

Last Updated : 23 Feb, 2021
Comments
Improve
Suggest changes
Like Article
Like
Report

The toInt() method is utilized to convert the specified int number into float int type value.
 

Method Definition: (Number).toIntReturn 
Type: It returns the converted int datatype value. 


Example 1: 

Scala
// Scala program of Int toInt()
// method

// Creating object
object GfG
{ 

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

Output: 
1

 

Example 2: 

Scala
// Scala program of Int toInt()
// method

// Creating object
object GfG
{ 

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

Output: 
12

 

Article Tags :

Similar Reads