Scala Long !=(x: Int)方法及示例
在Scala中,Long是一个64位的带符号整数,相当于Java中的 long 基本类型。方法 !=(x: Int) 用于检查给定的 Long 值和 int 值是否相等。
方法定义 – def !=(x: Int): Boolean
返回值 – 如果此值不等于 x,则返回 true,否则返回 false。
示例 #1:
// Scala 程序用于解释 Long !=(x: Int) 函数的运行
// 创建对象
object GfG
{
// 主要方法
def main(args:Array[String])
{
// 应用 !=(x: Int) 函数
val result = (10).toLong.!=(10:Int)
// 显示输出
println(result)
}
}
输出:
false
示例 #2:
// Scala program to explain working
// of Long !=(x: Int) function
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying !=(x: Int) function
val result = 1186000000.toLong.!=(1296:Int)
// Displays output
println(result)
}
}
输出:
true
阅读更多:Scala 教程
极客教程