The five arithmetic assignment operators are a form of short hand. Various textbooks call them "compound assignment operators" or "combined assignment operators". Their usage can be explaned in terms of the assignment operator and the arithmetic operators.
Compound Operator | Sample Expression | Expanded Form |
---|---|---|
+= | x+=2 | x=x+2 |
-= | y -=6 | y=y-6 |
*= | z *=7 | z=z*7 |
/= | a /=4 | a=a/4 |
%= | b %=9 | b= b%9 |
An assignment operator is used for assigning a value to a variable. The most common assignment operator is =
public class Assignment { public static void main(String args[]) { int a=123; System.out.println(a); a+=10; System.out.println(a); a-=10;//a=a-10 System.out.println(a); a*=10; System.out.println(a); a/=10; System.out.println(a); a%=10; System.out.println(a); } }
123 133 123 1230 123 3To download raw file Click Here
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions