Scala Int isValidInt() 方法与示例
如果指定的 int 数为零或位于 scala.int MinValue 和 MaxValue 的范围内,则使用isValidInt()方法返回 true;否则返回假。
Method Definition: (Int_Number).isValidIntReturn
Type: It returns true if the specified number is either zero or lies within
the range of scala.int MinValue and MaxValue; otherwise returns false.
示例 1:
Scala
// Scala program of Int isValidInt()
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying isValidInt method
val result = (0).isValidInt
// Displays output
println(result)
}
}
Scala
// Scala program of Int isValidInt()
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying isValidInt method
val result = (5.9).isValidInt
// Displays output
println(result)
}
}
输出:
true
示例 2:
斯卡拉
// Scala program of Int isValidInt()
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying isValidInt method
val result = (5.9).isValidInt
// Displays output
println(result)
}
}
输出:
false