Scala Short -(x: Short)方法及示例
利用-(x: Short)方法,可以找到所述Short值与Short类型的’x’之间的差。
方法定义:def -(x: Short):Int
返回类型。它返回Int。
例如:1#。
// Scala program of -(x: Short)
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying -(x: Short) method
val result = (999).-(1000)
// Displays output
println(result)
}
}
输出。
-1
例如:2#
// Scala program of -(x: Short)
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying -(x: Short) method
val result = (994).-(-1000)
// Displays output
println(result)
}
}
输出。
1994
极客教程