The toShort() method is utilized to convert a stated character into type Short.
Method Definition: def toShort: Short
Return Type: It returns Short.
Example: 1#
// Scala program of toShort() // method // Creating object object GfG
{ // Main method
def main(args : Array[String])
{
// Applying toShort method
val result = '\u5555' .toLong
// Displays output
println(result)
}
} |
Output:
21845
Example: 2#
// Scala program of toShort() // method // Creating object object GfG
{ // Main method
def main(args : Array[String])
{
// Applying toShort method
val result = '\u1111' .toShort
// Displays output
println(result)
}
} |
Output:
4369