Scala Int <<(x: Byte)方法及其例子
**<<(x: Byte) ** 方法用于将int值左移指定的字节位数,并返回对应的值。
方法定义:(Int_Value).<<(Byte_Value)
返回类型:int值左移指定的字节位数后的结果。
例子 #1:
// Scala program of Int <<(x: byte)
// method
// 创建对象
object GfG
{
// Main方法
def main(args:Array[String])
{
// 应用Int <<(x: byte)函数
val result = (15).<<(2)
// 显示结果
println(result)
}
}
60
例子 #2:
// Scala program of Int <<(x: Byte)
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying Int <<(x: Byte) function
val result = (15).<<(3)
// Displays output
println(result)
}
}
120
阅读更多:Scala 教程
极客教程