❮ Previous Next ❯

Java Relational Operators:

Relational operators are binary operators. Java supports six relational operators which are as follows :

== //equal to
!= // not equal to
> // greater than
>= // greater than or equal to
< // less than
<= // less than or equal to

These operators are used when some comparisons will arise between two operands. For example, Let the value of a and b is 15 and 20 respectively.

If write a<b, then it is a case of comparison. This relational expression is evaluated as either true or false. So the value this expression is true. Let's see a program to understand these operators.

Example

Class RelationalDemo
{
public static void main(String args[])
{
int x=10,y=15,z=20;
boolean p;
boolean q;
p=x<y;
q=y>z;
System.out.println(x);
System.out.println(y);
System.out.println(z);
System.out.println(p);
System.out.println(q);
}
}
Output:

10
15
20
true
false

❮ Previous Next ❯

Follow Us




  Tutorials

Popular Links

Contact Us

address Plot No-741,2ND Floor
Opp. Bhagabati Temple,Jayadev Vihar
      Bhubaneswar-751013
      Email: info@silantechnology.com
      Phone: 0674-2361252
address
39877, sundale dr, apt#101, Fremont, California 94538, USA
       Phone: +1(262)388-7619

facebook twitter google linked in

© 2018 Silan Technology. All Rights Reserved