Open In App

Scala Int toByte() method with example

Last Updated : 04 Feb, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

The toByte() method is utilized to convert the specified int number into Byte data type value.

Method Definition: (Number).toByte

Return Type: It returns the converted byte datatype value.

Example #1:




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


Output:

66

Example #2:




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


Output:

-127


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads