The assignment operator is the single equal sign =
.
The assignment operator works in Java much same as other computer language.
The assignment operators in Java are listed in following table:
Operator | Description | Usage | Example |
= | Assignment Assign the value of the LHS to the variable at the RHS. | var = value or expr | x = 5; |
+= | Compound addition and assignment. | var += value or expr | x += 5; |
-= | Compound subtraction and assignment. | var -= value or expr | x -= 5; |
*= | Compound multiplication and assignment. | var *= value or expr | x *= 5; |
/= | Compound Division and assignment | var /= value or expr | x /= 5; |
%= | Compound Reminder (Modulus) and assignment | var %= value or expr | x %= 5; |
Ask Question