Scala Int <<(x: Int) 方法及示例
<<(x: Int) 方法用于将 int 值按指定的 int 值左移,返回结果。
方法定义:(Int_Value).<<(Int_Value)
返回类型:返回 int 值按指定的 int 值左移的结果。
示例 #1:
// Scala program of Int <<(x: Int)
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying Int <<(x: Int) function
val result = (15).<<(2)
// Displays output
println(result)
}
}
60
示例 #2:
// Scala program of Int <<(x: Int)
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying Int <<(x: int) function
val result = (15).<<(3)
// Displays output
println(result)
}
}
120
阅读更多:Scala 教程
极客教程