Scala Int unary_~ 方法与示例
unary_~方法用于返回指定 int 值的按位否定。
Method Definition: (Int_Value).unary_~
Return Type: It returns the bitwise negation of the specified int value.
示例 #1:
// Scala program of Int unary_~
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying unary_~ function
val result = (65).unary_~
// Displays output
println(result)
}
}
输出:
-66
示例 #2:
// Scala program of Int unary_~
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying unary_~ function
val result = (115).unary_~
// Displays output
println(result)
}
}
输出:
-116