The toInt() method is utilized to convert the specified number into integer value.
Method Definition: (Number).toInt
Return Type: It returns the converted integer value.
Example #1:
// Scala program of Float toInt() // method // Creating object object GfG
{ // Main method
def main(args : Array[String])
{
// Applying toInt method
val result = ( 9.7 ).toInt
// Displays output
println(result)
}
} |
Output:
9
Example #2:
// Scala program of Float toInt() // method // Creating object object GfG
{ // Main method
def main(args : Array[String])
{
// Applying toInt method
val result = ( 9 ).toInt
// Displays output
println(result)
}
} |
Output:
9