javatutelearn.com
Easy Learning
Search Javatutelearn.com :
Operator | Purpose |
---|---|
== | Equal to |
!= | Not equal to |
> | Greater than |
< | Less than |
>= | Greater than or equal to |
<= | Less than or equal to |
class RelOp { public static void main(String args[]) { int a=30; int b=30; System.out.println("Value of a is " + a); System.out.println("Value of b is " + b); if (a == b){ System.out.println("a is equal to b"); } a = 10; b = 20; System.out.println("Value of a is " + a); System.out.println("Value of b is " + b); if (a != b){ System.out.println("a is not equal to b"); } System.out.println("Value of a is " + a); System.out.println("Value of b is " + b); if (b > a){ System.out.println("b is greater than a"); } System.out.println("Value of a is " + a); System.out.println("Value of b is " + b); if (a < b){ System.out.println("a is less than b"); } a = 50; b = 40; System.out.println("Value of a is " + a); System.out.println("Value of b is " + b); if (a >= b){ System.out.println("a is greater than b"); } System.out.println("Value of a is " + a); System.out.println("Value of b is " + b); if (b <= a){ System.out.println("b is less than a"); } } }
Value of a is 30 Value of b is 30 a is equal to b Value of a is 10 Value of b is 20 a is not equal to b Value of a is 10 Value of b is 20 b is greater than a Value of a is 10 Value of b is 20 a is less than b Value of a is 50 Value of b is 40 a is greater than b Value of a is 50 Value of b is 40 b is less than a