当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Scala Int isValidInt()用法及代码示例


如果指定的int数为零或在scala.int范围之内,则使用isValidChar()方法返回true。否则返回false。

函数定义: (Int_Number).isValidInt

返回类型: 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 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) 
      
    } 
} 
输出:
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


相关用法


注:本文由纯净天空筛选整理自Kanchan_Ray大神的英文原创作品 Scala Int isValidInt() method with example。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。