Skip to content
Related Articles

Related Articles

Improve Article

Scala Char toShort() method with example

  • Last Updated : 29 Oct, 2019

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



My Personal Notes arrow_drop_up
Recommended Articles
Page :