Relational Operators:
Operator Meaning
-------- -------
== equal to
!= not equal to
> greater than
< leass than
>= greater than or equal to
<= less than or equal to
e.g.
//logical operators in java
class lo {
public static void main(String ar[]) {
int a, b;
a=8; b=8;
if(a==b) System.out.println("Value of a is equal to b");
a=0; b=8;
if(a!=b) System.out.println("Value of a is not equal to b");
a=8; b=2;
if(a>b) System.out.println("Value of a is big");
a=8; b=18;
if(a=b) System.out.println("Value of a is greater than or equal to b");
a=5; b=8;
if(a<=b) System.out.println("Value of a is less than or equal to b");
}
}
to compile : c:\myjavaprog>javac lo.java
to run : c:\myjavaprog>java lo
output:
Value of a is equal to b
Value of a is not equal to b
Value of a is big
Value of b is big
Value of a is greater than or equal to b
Value of a is less than or equal to b