Scala - Relational Operators


Advertisements


Try the following example program to understand all the relational operators available in Scala Programming Language.

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) );
   }
}

Save the above program in Demo.scala. The following commands are used to compile and execute this program.

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

scala_operators.htm

Advertisements