6. Operators in java :

There are multiple operators in java.
They are listed below:
 
. Arthimetic operator
. Assignment opearator 
. Relational operator
. Logical operator
. Increment and Decrement operator
. Conditional operator
. Bitwise operator
. Unary operator
. Other operators


*Arthimetic operator:
  These operator is used to perform mathematical operations like; Addition, Subtraction, Multiplication, Division, Modular division. 

Operator           Description
     +                   Additive operator
     -                   Subtractive operator
     *                   Multiplicative operator
     /                   Division operator
     %                  Modular operator 

* Assignment operator
      
    It assigns the value to the variable.

Example:
     . int x = 15;
             x = 15;
   
     . int class = 12;
             class = 12; 
Operator     Example     Equivalent to
     =                 a=b.                a=b;
    +=               a+=b              a=a+b;
    -=                a-=b                a=a-b;
    *=                a*=b               a=a*b;
    /=                a/=b.              a=a/b;
    %=              a%=b               a=a%b; 

Let see a programme for above two operators:
 
  package test package;
 public class Arthimetic Demo{
 public static void main (string [] args){
int results = 1+2;

// result id now 3
system.out.println("1+2=" +result);
int original_result=result;
result=result-1;

//result is now 2
system.out.priintln(original_result + "-1=" + result);
Original_result=result;
result=result*2;

//result is now 4
system.out.priintln(original_result + "*2=" result );
Original_result=result;
result=result / 2;

//result is now 2
system.out.println(original_result+ "+8="result);
Original_result=result;
result=result+8;

//result is now 10
system.out.priintln(original_result+ "+8=" result);
Original_result=result;
result=result%7;

//result is now 3
system.out.println(original-result+ "%7="+result);
    }
}
 
Output:
  1+2=3
  3-1=2
  2*2=4
  4/2=2
  2+8=10
  10%7=3


*Relational operator:
    Relational operator is also known as Equality operator. Relational operator is generally defined as : greater than, less than, equall to, not equall to,greater than are equall to and less than are equall to other operands. 
Operator                 Explanation
     ==                         equal to 
     !=                         Not equal to
     >                          Greater than
    <                           Less than
    >=                        Greaterthan are equal to
   <==.                      Lessthan are equal to 

Some people called as Equality operator And some people called as Relational operator.

Program:
 package test package;
 public class Relational Operator {
 public static void main ( string [] arg)
  {
  int value 1 = 1;
  int value 2 = 2;
if(value 1 == value 2)
system.out.println(" value 1==value 2");
if(value 1 != value 2)
system.out.println("value 1 != value 2");
if(value 1 > value 2)
system.out.println("value 1 > value 2");
if (value 1 >= value 2)
system.out.println("value1 >= value 2");
if(value 1 < value 2)
system.out.println("value 1 < value 2");
if(value 1 <= value 2)
system.out.println("value1 <= value2");
  }
}


Outout:
  value 1 != value 2
  value 1 < value 2
  value 1 <= value 2

*Logiocal operator:
   It is ude to check, the given option is true (or) false.
 
Operator Meaning
  && Logical AND
   || Logical OR
   ! Logical nOT

Program:
 public class Logical operator{
 public static void main(string [] arg)
{

 //&& operator
system.out.println((5>3)&&(8>5));//true
system.out.println((5>3)&&(8<));//false

// || operator
system.out.println((5<3)||(8<5));//true
system.out.println((5<3)||(8<5));//true
system.out.println((5<3)||(8<5));//false

// ! operator
system.out.println(!(5==3));//true
system.out.println(!(5>3));//false
  }
}


*Increment And Decrement operator:
   Increment operator means increased(++) 1 to the given value.
   Decrement(--) operator means decresed 1 to the given value.

Program:
 class main Increment And Decrement Operator {
public static void main(string [] arg) 
{
// declare variables
 int a=12 , b=12;
 int result 1, result 2;

// original value
system.out.println("value of a:" +a);

// increment operator
result 1 = ++a;
system.out.println(" After increment :" +result 1);
system.out.println ("value of b:" +b);

// decrement operator
result 2 == --b:
system.out.println(" After decrement:" +result 2 );
   }
}
 
Output:
  value of a : 12
  After increment : 13
  value of b = 12
  After decrement : 11
 
*Conditional operator:
   Conditional operator are perform on Boolean expressions.
  && and || are conditonal operatro
  && = conditional AND
  || = conditional OR

Program:
 package test package 1;
 public class Conditional operator {
 public static void main( string [] args){
 int value 1 = 1;
 int vlaue 2 =2;
if((value 1==1)&&(value 2==2))
{
system.out.println("value 1 is 1 AND value 2 is 2");
}
if((value 1==1)||(value 2==1))
system.out.println("value 1 is 1 OR value 2 is 1");
// int value 1 = 1;
// int value 2 = 2;
// int results;
// boolean some Condition = true;
// result = Some Condition?value1 :value2;
// system.out.println(result);
  }
}

Output:
  value 1 is 1 AND value 2 is 2
   value 1 is 1 OR value 2 is 1 

*Bitwise operator:
    Bitwise Complement Operator of 35 

    35 = 00100011 (In Binary)
     ~ 00100011
            11011100 = 220 ( In Decimal)

Note: 0's are converted into 1's.
           1's are converted into 0's.

*Unary operator:
  Used with in only one operand. 
Operator                        Meaning
      +                             Unary plus
       -                             Unary minus
      ++                        Increment operator
      --                           Decrement operator
      !                              Logical operator 
*Other operators in java:
           These are additional operators in java.
 
. Java instance of operator:
   It checks, whether an object is an instance of a particular class (or) not.
  
Program:
  
 package star code learners;
 class main Instance of OPeratro{
public static void main(string [] arg){
String str = "programise";
boolean result;
// checks if str is instance of 
// the String class
result = str instance of String;
system.out.println("Is str an object of string ?" + result);
    }
}

Output:
  Is str an object of string? true.

. Java Ternary operator:
       It is nothing but conditional operator.

variable=Expression ? expression 1 expression 2.

Program:
 package star code leaners;
class Java Ternary Operators{
public static void main(string [] args){
int february Days = 29;
String results;
// ternary operators
result = ( february Days==28)?"Not a leap year:"Leap year;
system.out.println(result);
  }
}

Output:
  Leap year.

. Shift operator in java :
      The shift operator is used to shifts the bits of a number to left or right,there by multiplying or dividing the number.
  They are three types of shift operators are there.
Namely Left shift operator (<<), signed right shift operator (>>) and unsigned right shift operator.

Let see a syntax for this operator;
 number shift_op number_ of_ places_to_shift;

We will go for a example program, then understand easily.

program:
 package star code leaners;
class Java Shift OPerators{
public static void main( string [] args ){
int a = 68;
system.out.println(a<<2);//232=11101000
system.out.println(a>>2);//returns 14=1110
system.out.println(a>>>2);//returns 14
   }
}

. Java left shift operator;
       The java left shift operator(<<) is used to shifts all the bits in a value to the left side of a required number of times.

Example:
 package star code leaners.
 class Left Shift Operator {
public static void main( string args [] ){
system.out.println(10<<2);// 10*2^2 = 10*4=40
system.out.println(20<<2);//20*2^2=20*4=80
system.out.println(10<<2);//10*2^3=20*4=80
system.out.println(15<<4);//15*2^2=15*16=240
  }
}

Output:
    40
    80
    80
   240 

. Java right shift operator:
   This operator is similar to left shift operator.The rigght shift>> operator in java, it moves the values in left side operand to right the number of bits required by the right operand.

Program:
  package star code leaners;
class Right Shift Operand;
public static void main( string [] arg ){
system.out.println(10>>2);//10/2^2=10/4=2
system.out.prinltn(20>>2);// 20/2^2=20/4=5
system.out.println(20>>3);// 20/2^2=20/8=2
   }
}
 
Output:
    2
    5
    2


That's it guys !. Once we recall whatever we disscussed in the session. Types of operators and other operators are disscussed.
  Mostly we all used Types of operators ,we use rarely the other operators. Mostly we don't know about the other operators in java. But we need to about that also that's why i explained.