Scala 中 Char +(x: Int) 方法及其示例
该方法用于计算指定字符值与整数类型的变量‘x’的和。
方法定义: def +(x: Int): Int
返回类型: 返回 Int 类型。
示例 1#:
// Scala program of +(x: Int)
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying +(x: Int) method
val result = 'A'.+(10)
// Displays output
println(result)
}
}
75
示例 2#:
// Scala program of +(x: Int)
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying +(x: Int) method
val result = 'A'.+(11)
// Displays output
println(result)
}
}
76
更多Scala相关文章,请阅读:Scala 教程
极客教程