带有示例的 Scala Float toString() 方法
toString()方法用于将指定的数字转换为字符串数据类型值。
Method Definition: (Number).toString
Return Type: It returns the converted String datatype value.
示例 #1:
// Scala program of Float toString()
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying toString method
val result = (56).toString
// Displays output
println(result)
}
}
输出:
'56'
示例 #2:
// Scala program of Float toString()
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying toString method
val result = (56.9).toString
// Displays output
println(result)
}
}
输出:
'56.9'