Scala Char toShort() 方法及示例
toShort() 方法用于将指定字符转换为Short类型。
方法定义:def toShort: Short
返回类型:返回Short。
示例:1#
// Scala toShort() 方法示例
// 创建对象
object GfG {
// 主方法
def main(args: Array[String]) {
// 调用toShort方法
val result = '\u5555'.toLong
// 输出结果
println(result)
}
}
21845 ```
示例:2#
// Scala toShort() 方法示例
// 创建对象
object GfG {
// 主方法
def main(args: Array[String]) {
// 调用toShort方法
val result = '\u1111'.toShort
// 输出结果
println(result)
}
}
4369 ```
更多Scala相关文章,请阅读:Scala 教程
极客教程