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 教程
极客教程