Scala Int toShort() method with example
Last Updated :
23 Feb, 2021
The toShort() method is utilized to convert the specified int number into a short type value.
Method Definition: (Number).toShort
Return Type: It returns the converted short datatype value.
Example 1:
Scala
object GfG
{
def main(args : Array[String])
{
val result = ( 1 ).toShort
println(result)
}
}
|
Example 2:
Scala
object GfG
{
def main(args : Array[String])
{
val result = ( 187449572 ).toShort
println(result)
}
}
|
Share your thoughts in the comments
Please Login to comment...