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