Scala short &(x: Byte)。Int

Scala short &(x: Byte)。Int

Short,一个16位有符号的整数(相当于Java的short原始类型)是scala.AnyVal的一个子类型。利用&(x: Int)方法,可以返回Int值对指定字节值进行位数和运算的结果。

方法定义: def +(x: Byte):Int

返回类型。它返回Int。

例子 #1:

// Scala program of Short &(x: Byte) 
// method 
  
// Creating object 
object GfG 
{ 
  
    // Main method 
    def main(args:Array[String]) 
    { 
      
        // Applying Short &(x: Byte) function 
        val result = (998.toShort).&(125:Byte)
          
        // Displays output 
        println(result) 
      
    } 
} 

输出。

100

例子#2。

// Scala program of Short &(x: Short) 
// method 
  
// Creating object 
object GfG 
{ 
  
    // Main method 
    def main(args:Array[String]) 
    { 
      
        // Applying Short &(x: Short) function 
        val result = (-111.toShort).&(47:Byte)
          
        // Displays output 
        println(result) 
      
    } 
} 

输出。

1

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程