Site icon DataFlair

Java Operators and Its Types with Examples

Get Job-ready: Java Course with 45+ Real-time Projects! - Learn Java

Program 1

/* 
  
  > < >= <= == !=  Relational 
  
  ++  --  Incr Decr  // Type Casted
  
  && || ! Logical 

  & |  Boolean Logical

  & |  ^    ~  <<    >>     >>>    Bitwise operator

   ? : conditonal operator

 Arithmatical  += -= /= *= %=

*/ 
class TestOperator
{
      public static void main(String args[])
      {
             // int a=5,b;
              //a=(short)(a+1);  // max(int,type of operand,type of second operand)  
              // b=--a;  // a=a-1   b=a  
               //b=a--;  // b=a   a=a-1
                 //b=++a + a++;
            //   System.out.println(a);
            //   System.out.println(b);
                 //System.out.println(!(50<10  && 30>10));
                 //System.out.println( 50>10  || 30<10);
                //  byte a=50,b=20;
                //   System.out.println(++a>20 | ++b>2);  //true
                //   System.out.println(a); // 51
                //   System.out.println(b);  // 21
                int a,b;
                a=50;
                
                String S;
                S=a%2==0?"Even":"Bye";
                System.out.println(S);
                         
      }

}

 

Exit mobile version