Scala Int toString() 方法与示例
toString()方法用于返回指定值的字符串表示形式。
Method Definition: def toString(): String
Return Type: It returns the string representation of the specified value.
示例 #1:
// Scala program of Int toString()
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying toString method
val result = (65).toString
// Displays output
println(result)
}
}
输出:
65
示例 #2:
// Scala program of Int toString()
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying toString method
val result = (1515).toString
// Displays output
println(result)
}
}
输出:
1515