带有示例的 Scala Char toShort() 方法
toShort()方法用于将指定字符转换为 Short 类型。
Method Definition: def toShort: Short
Return Type: It returns Short.
示例:1#
// Scala program of toShort()
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying toShort method
val result = '\u5555'.toLong
// Displays output
println(result)
}
}
输出:
21845
示例:2#
// Scala program of toShort()
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying toShort method
val result = '\u1111'.toShort
// Displays output
println(result)
}
}
输出:
4369