Scala Long &(x: Int)方法
在Scala中,Long是一个64位有符号整数,相当于Java的long原始类型。利用 **& (x: Int) **方法,可以返回指定的Long值和Int值的Bitwise AND。
方法定义 – def &(x: Int)
返回 – 返回该值与x的位数和。
例子 #1 :
// Scala program to explain working of
// &(x: Int) method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying &(x: Int) method
val result = (13.toLong).&(28:Int)
// Displays output
println(result)
}
}
输出
12
例子#2
// Scala program to explain working of
// &(x: Int) method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying &(x: Int) method
val result = (7.toLong).&(11:Int)
// Displays output
println(result)
}
}
输出
3
极客教程