Scala Byte toInt() method
在Scala中,Byte是一个8位有符号整数(相当于Java的byte原始类型)。 toInt()方法用于将指定数字转换为Int数据类型值。
方法定义:(Number).toInt
返回类型:返回转换后的Int值。
示例1:
// Scala program of Byte toInt()
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying toInt method
val result = (13).toInt
// Displays output
println(result)
}
}
输出:
13
示例2:
// Scala program of Byte toInt()
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying toInt method
val result = (123.4).toInt
// Displays output
println(result)
}
}
输出:
123
更多Scala相关文章,请阅读:Scala 教程