Scala Byte &(x: Int): Int
在Scala中,Byte是一个8位有符号整数(相当于Java的byte原始类型)。&(x:Int)方法用于返回该值与x的按位AND。
方法定义: Byte &(x: Int): Int
返回类型: 它返回该值与x的按位AND。
示例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)
}
}
输出:
37
示例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)
}
}
输出:
0
更多Scala相关文章,请阅读:Scala 教程