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