Scala Int toInt() method with example

Scala Int toInt() method with example

toInt() 方法用于将指定的整型数转换为浮点整数类型值。

**方法定义** :(数字). toInt 
**返回类型** :返回转换后的整型数据值。

示例1:

// Scala程序的Int toInt()方法
// Creating object
object GfG
{
    // Main method
    def main(args: Array[String])
    {
       // Applying toInt method
       val result = (1).toInt
         
       // Displays output
       println(result)
    }
}

输出:

1

示例2:

// Scala程序的Int toInt()方法
// Creating object
object GfG
{
    // Main method
    def main(args: Array[String])
    {
       // Applying toInt method
       val result = (12).toInt
         
       // Displays output
       println(result)
    }
}

输出:

12

阅读更多:Scala 教程

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程