Monday, 26 January 2015

Arithmetic Compound Assignment Operators

Java Arithmetic Compound Operator

Compound Assignment Operators in Java

               Java gives special operators to combine an arithmetic operator with an assignment and which is known as Compound Assignment Operator. This session describes how it works and its benefits.

Consider the following addition and subtraction statements,

                         a = a + 5;
                         b = b - 5;

These statements can be rewritten as follows with the help of Compound Assignment Operator.

                         a += 5;
                         b -= 5;

Compound Assignment operators are available for all arithmetic and binary operators.


General Form:

                        var = var op expression;

Compound assignment Operator Form:

                         var op= expression;


 General Form  Compound Assignment Operator Form
 a = a - 5;  a -= 5;
 a = a + 5;  a += 5
 a = a % 5;  a %= 5
 a = a / 5  a /= 5
 a = a * 5  a *= 5

Advantages of Compound Assignment Operators

          The Compound Assignment Operators are used by Java Professionals to attain two major benefits.

          1. Compound Assignment Operators are shorthand and saves a few letters every time when you type Java Code.

          2. It is efficient than its equivalent long form in some cases.


  1. If you're in the middle of writing an essay or term paper for class, or several classes, you know that time management is something that is very important. After all, you want to make sure that you not only get your assignments finished on time but give them enough time to be proofread and edit it before handing it in. do my programming assignment

  2. Kids educational toys serve a much larger purpose besides simply giving your child something to play with, and keeping the out of your hair. Kids educational toys do just that; they create opportunities for your child to grow mentally, and to learn tools and functioning skills that they will need to call upon for their success as an adult. As a matter of fact, this is the main reason why parents want their children to have educational toys.academic writing

  3. I believe there are many more pleasurable opportunities ahead for individuals that looked at your site.
    java training in chennai

  4. You can have them stroll around the city, stop and talk to other sims, go to sleep so their energy is replaced, and more. Projectsdeal Review