Skip to content
Related Articles

Related Articles

Scala Char toByte() method with example
  • Last Updated : 29 Oct, 2019

The toByte() method is utilized to convert a stated character into the type Bytes.

Method Definition: def toByte: Byte

Return Type: It returns Bytes of the character stated.

Example: 1#




// Scala program of toByte()
// method
  
// Creating object
object GfG
  
    // Main method
    def main(args:Array[String])
    {
      
        // Applying toByte method
        val result = 'A'.toByte
          
        // Displays output
        println(result)
      
    }
Output:



65

Example: 2#




// Scala program of toByte()
// method
  
// Creating object
object GfG
  
    // Main method
    def main(args:Array[String])
    {
      
        // Applying toByte method
        val result = 'a'.toByte
          
        // Displays output
        println(result)
      
    }
Output:
97

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up
Recommended Articles
Page :