📜  Scala Int toInt() 方法与示例

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

Scala Int toInt() 方法与示例

toInt()方法用于将指定的 int 数转换为 float int 类型的值。

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

示例 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)
     
    }
}


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


输出:
1

示例 2:

斯卡拉

// 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)
     
    }
}
输出:
12