Scala Int isWhole() 方法与示例
isWhole()方法用于在指定的 int 数不包含任何小数部分时返回 true,否则返回 false。
Method Definition: (Int_Number).isWhole
Return Type: It returns true if the specified int number is not having any decimal component, otherwise, it returns false.
示例 #1:
// Scala program of Int isWhole()
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying isWhole method
val result = (5).isWhole
// Displays output
println(result)
}
}
输出:
true
示例 #2:
// Scala program of Int isWhole()
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying isWhole method
val result = (5.0).isWhole
// Displays output
println(result)
}
}
输出:
false