Open In App

Scala Char toShort() method with example

Improve
Improve
Like Article
Like
Save
Share
Report

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


Last Updated : 29 Oct, 2019
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads