Scala Byte +(x: Short): Int
在Scala中,Byte是一个8位有符号整数(相当于Java的byte原始类型)。使用+(x: Short)方法来返回该值与x的和。
方法定义: Byte +(x: Short): Int
返回类型: 它返回该值与x的和。
例1:
// Scala program of Byte +(x: Short)
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying Byte +(x: Short) function
val result = (167.toByte).+(125:Short)
// Displays output
println(result)
}
}
输出:
36
例2:
// Scala program of Byte +(x: Short)
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying Byte +(x: Short) function
val result = (167.toByte).+(2:Short)
// Displays output
println(result)
}
}
输出:
-87
更多Scala相关文章,请阅读:Scala 教程
极客教程