Friday, June 10, 2016

Relational Operator

Relational operator is an operator that declare the relation between the operand with the other operand. There are: equal to, not equal to, greater than, less than, greater than or equal to, less than or equal to. Result is given of an operation that involves relational operator will be boolean (true/false). The following table shows list of relational operator in Java:

  Operator   Description
  ==   Equal to
  !=   Not equal to
  >   Greater than
  <   Less than
  >=   Greater than or equal to
  <=   Less than or equal to


Operator == and != can be applied to any type, either numeric, character, or boolean. And the four other operators can only be used for numeric and char type, to determine whether an operand is greater than or less than the other operand. Consider the following code example:

int a = 5, b = 10;
boolean c = a > b;

Here, the value of c would be false, because value of b is greater than the value of a. In general, the relational operators used in the expression (either on the decision making or looping). Here is an example of code that will demonstrate the use of relational operator in the program.

class RelationalOperatorDemo {

   public static void main(String[] args) {

      int a=5, b=10;

      System.out.println("a == b is " + (a == b));
      System.out.println("a != b is " + (a != b));
      System.out.println("a > b is " + (a > b));
      System.out.println("a < b is " + (a < b));
      System.out.println("a >= b is " + (a >= b));
      System.out.println("a <= b is " + (a <= b));
   }
}

The results will be given by the above program as follows:

a == b is false
a != b is true
a > b is false
a < is true
a >= b is false
a <= b is true

3 comments:

  1. How do casino sites work? - DrMCD
    If 계룡 출장안마 you can't tell us how you 시흥 출장마사지 can play with a slot machine, then this is the 거제 출장샵 best casino website. There 광양 출장샵 is 경기도 출장샵 a slot machine, which you will see when you

    ReplyDelete
  2. Thank you for sharing valuable information with us.

    Java web application is a type of free programming language used to develop applications and software that are becoming highly in demand on the internet. The software engineer can provide the web application or software in the form of windows, Linux, and MAC OS. There are various types of systems that can not work without java and it is getting necessary day by day even the world’s no.1 application depends on java. Java has become a most popular feature in android smartphone applications that's why Aptech learning provides java training in Dwarka, Janakpuri, and in Gurgaon also. Java training helps to get you complete knowledge about web frameworks, Java testing tools, and design patterns in java.

    Let's get learn about the PHP training course
    PHP is a type of programming language that is most commonly used in dynamic functions such as modifying, collecting, and deleting all types of databases It also helps to encrypt all types of data in the form of HTML and XML file. Aptech learning provides you with a complete PHP training course at a reasonable cost that will help you to grow more in the era of the software industry.

    For more details please visit our website : Aptech Gurgaon

    ReplyDelete