Open In App

Scala Float toInt() method with example

Improve
Improve
Like Article
Like
Save
Share
Report

The toInt() method is utilized to convert the specified number into integer value.

Method Definition: (Number).toInt

Return Type: It returns the converted integer value.

Example #1:




// Scala program of Float toInt()
// method
  
// Creating object
object GfG
  
    // Main method
    def main(args:Array[String])
    {
      
        // Applying toInt method
        val result = (9.7).toInt
          
        // Displays output
        println(result)
      
    }


Output:

9

Example #2:




// Scala program of Float 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:

9


Last Updated : 29 Oct, 2019
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads