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