Scala – Relational Operators

scala relational operators

In this guide, we will discuss Scala Relational Operators. 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

Next Topic : Click Here

This Post Has 2 Comments

Leave a Reply