Scala Byte %(x: Short): Int

Scala Byte %(x: Short): Int

在Scala中,Byte是一个8位有符号整数(相当于Java的byte原始类型)。方法%(x: Short)用于返回除以x的余数。

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

例子#1:

//Scala program of Byte %(x: Short)
//method

//Creating object 
object GfG 
{ 

    //Main method 
    def main(args:Array[String]) 
    { 

        //Applying Byte %(x: Short) function 
        val result = (100.toByte).%(3:Short) 

        //Displays output 
        println(result) 

    } 
}

输出:

1

例子#2:

//Scala program of Byte %(x: Short)
//method

//Creating object 
object GfG 
{ 

    //Main method 
    def main(args:Array[String]) 
    { 

        //Applying Byte %(x: Short) function 
        val result = (167.toByte).%(3:Short) 

        //Displays output 
        println(result) 

    } 
}

输出:

-2

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

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程