Show 例子 2
优质
小牛编辑
133浏览
2023-12-01
尝试以下示例程序以了解Scala编程语言中可用的所有关系运算符。
例子 (Example)
object Demo {
def main(args: Array[String]) {
var a = 10;
var b = 20;
println("a == b = " + (a == b) );
println("a != b = " + (a != b) );
println("a > b = " + (a > b) );
println("a < b = " + (a < b) );
println("b >= a = " + (b >= a) );
println("b <= a = " + (b <= a) );
}
}
将上述程序保存在Demo.scala 。 以下命令用于编译和执行此程序。
Command
\>scalac Demo.scala
\>scala Demo
输出 (Output)
a == b = false
a != b = true
a > b = false
a < b = true
b >= a = true
b <= a = false