带有示例的 Scala Char toChar() 方法
toChar()方法用于返回自身。
Method Definition: def toChar: Char
Return Type: It returns Char.
示例:1#
// Scala program of toChar()
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying toChar method
val result = 'A'.toChar
// Displays output
println(result)
}
}
输出:
A
示例:2#
// Scala program of toChar()
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying toChar method
val result = '9'.toChar
// Displays output
println(result)
}
}
输出:
9