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