带有示例的 Scala Char isDigit() 方法
isDigit()方法用于检查指定的字符是否为数字。
Method Definition: def isDigit: Boolean
Return Type: It returns true if the stated character is digit else it returns false.
示例:1#
// Scala program of isDigit()
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying isDigit method
val result = '9'.isDigit
// Displays output
println(result)
}
}
输出:
true
示例:2#
// Scala program of isDigit()
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying isDigit method
val result = 'g'.isDigit
// Displays output
println(result)
}
}
输出:
false