📜  带有示例的 Scala Float toInt() 方法

📅  最后修改于: 2022-05-13 01:54:28.899000             🧑  作者: Mango

带有示例的 Scala Float toInt() 方法

toInt()方法用于将指定的数字转换为整数值。

示例 #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)
      
    }
} 
输出:
9

示例 #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)
      
    }
} 
输出:
9