Sunday, December 27, 2015

Relational Operator

Relational Operator:


Operators                             Result

==                                          Equql to

!=                                           Not Equal to

>                                            Greater Than

<                                             Lesser than

>=                                           Greater than or equal to

<=                                           Lesser than or equal to  




package javaapplication16;


public class RelationalOperatorDemo {
    public static void main(String[] args) {
        int a=1;
        int b=2;
        int c=1;
        if(a==c){
            System.out.println(" a is Equal to c"+a);
        }else{
            System.out.println("a is not equal to c");
        }
        
        if(a!=b){
            System.out.println("a is Not Equal to b");
        }
        
        if(a>b){
            System.out.println("a is greater than b");
        }
           if(a<b){
               System.out.println("a is less than b");
           }  
           
           if(a>=b){
               System.out.println("a is greater or eual to b");
           }else{
            System.out.println("a is  not greater or eual to b");
           }
           
           if(a<=b){
               System.out.println("a is greater or equal to b");
           }else{
           System.out.println("a is not greater or equal to b");
           }
    }
}

Output:
 a is Equal to c1
a is Not Equal to b
a is less than b
a is  not greater or eual to b
a is greater or equal to b

0 comments:

Post a Comment