Open In App

Scala Int isValidInt() method with example

Last Updated : 23 Feb, 2021
Improve
Improve
Like Article
Like
Save
Share
Report

The isValidInt() method is utilized to return true if the specified int number is either zero or lies within the range of scala.int MinValue and MaxValue; otherwise returns false.
 

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.

Example 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)
     
    }
}


Output: 

true

 

Example 2: 

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)
     
    }
}


Output: 

false

 



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads