带有示例的 Scala Float toChar() 方法
toChar()方法用于将指定的数字转换为字符值。这里指定的数字是 ASCII 值。
Method Definition: (Number).toChar
Return Type: It returns the converted character value.
示例 #1:
// Scala program of Float toChar()
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying toChar method
val result = (66).toChar
// Displays output
println(result)
}
}
输出:
B
示例 #2:
// Scala program of Float toChar()
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying toChar method
val result = (80).toChar
// Displays output
println(result)
}
}
输出:
P