Scala Byte %(x: Int): Int

Scala Byte %(x: Int): Int

在Scala中,Byte是8位有符号整数(与Java的byte原始类型等效)。 该方法%(x:Int)方法用于返回该值除以x的余数

方法定义: Byte %(x: Int): Int
返回类型: 它返回该值除以x的余数。

示例1:

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

输出:

1

示例2:

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

输出:

-2

更多Scala相关文章,请阅读:Scala 教程

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程