Scala Int +(x: String)方法及示例
利用 + ( x: String) 方法,可以返回指定的int值和字符串值的总和。
方法定义:(Int_Value).+(String_Value)
返回类型。它返回指定的int值和字符串值的总和。
例子 #1 :
// Scala program of Int +(x: String)
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying Int +(x: String) function
val result = (100).+("GFG")
// Displays output
println(result)
}
}
输出。
100GFG
例子#2
// Scala program of Int +(x: String)
// method
// Creating object
object GfG
{
// Main method
def main(args:Array[String])
{
// Applying Int +(x: String) function
val result = (110).+("GEEKS")
// Displays output
println(result)
}
}
输出。
110GEEKS
极客教程