Scala Relational Operators

Advertisements


The following simple example program demonstrates the relational operators. Copy and paste the following Scala program in Test.scala file and compile and run this program.

object Test {
   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) );
   }
}

This would produce the following result:

C:/>scalac Test.scala
C:/>scala Test
a == b = false
a != b = true
a > b = false
a < b = true
b >= a = true
b <= a = false

C:/>


Advertisements
Advertisements