Scala Int toDouble() 方法与示例
toDouble()方法用于将指定的 int 数转换为 double 数据类型值。
Method Definition: (Number).toDouble
Return Type: It returns the converted double datatype value.
示例 #1:
// Scala program of Int toDouble()
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying toDouble method
val result = (1).toDouble
// Displays output
println(result)
}
}
输出:
1.0
示例 #2:
// Scala program of Int toDouble()
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying toDouble method
val result = (12).toDouble
// Displays output
println(result)
}
}
输出:
12.0