📜  Scala 字节 &(x: 字节): Int

📅  最后修改于: 2022-05-13 01:54:44.428000             🧑  作者: Mango

Scala 字节 &(x: 字节): Int

在 Scala 中,Byte 是一个 8 位有符号整数(相当于 Java 的 byte 原始类型)。 &(x:Byte) 方法用于返回此值与 x 的按位与。

示例 #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