Open In App

Scala Float toInt() method with example

Last Updated : 29 Oct, 2019
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


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads