Assignment Operators in Java
In this class, We discuss Assignment Operators in Java.
The reader should have prior knowledge of shift operators. Click here.
Equal to symbol is used for the assignment operator.
Assignment operator =
a=2, the value 2 is assigned to the variable a.
a=b, the value in b is assigned to the variable a.
a+=2 is same as a= a+2. we can write a shortcut.
a-=2 is the same as a= a-2
a*=b is the same as a= a*b
a/=2 is the same as a=a/b
a%=2 is the same as a= a%2
a&=2 is same as a = a&2
a|=2 is same as a = a|2
a^=2 is same as a = a^2
a<<=1 is same as a = a<<1
a>>=1 is same as a = a>>1
a>>>=1 is same as a = a>>>1