带有示例的 Scala Char toString() 方法
toString()方法用于将指定的字符转换为字符串。
Method Definition: def toString: String
Return Type: It returns the String representation of the stated character.
示例:1#
// Scala program of toString()
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying toString method
val result = 'B'.toString
// Displays output
println(result)
}
}
输出:
B
示例:2#
// Scala program of toString()
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying toString method
val result = 'b'.toString
// Displays output
println(result)
}
}
输出:
b