|
Do you need help with your Java programming?
Click here for instant help with your Java code. |
Assignment Operators in Java
The assignment operators store, or assign, a value into variables. The basic assignment operator is the equals sign (=), like: |
int i = 5; |
This basic assignment operator can however, and is often, used in combination with other types of operators. This is an example of how it is used in combination with the arithmetic operator (+): |
int i = 5; i += 5; //This is the same as writing i = i + 5; System.out.println(i); |
The output is: |
10 |
Other arithmetic operators in combination with the = operator: |
/= %= -= *= |
Shift operators can also be combined with the assignment operator: |
<<= >>= >>>= |
As can bitwise: |
&= |= ^= |
| Previous | Next | |
Tutorial Home | ||
| Do you know your Java? | |
| Take a Ten-Question-Java-Quiz! | |
Search for code examples on this site
