Basic Java Language: Difference between revisions

wikademia>Conrad.Irwin
rewrote touch on classes
Line 185: Line 185:
</pre>
</pre>


Subtraction, multiplication, and division, you have seen before, but the modulus operator is much less commonly used. Actually, it is commonly used, but it known under a different name, the remainder. Nine divided by four gives a remainder of one, so therefore 9 mod 4 evaluates to 1.
Subtraction, multiplication, and division, you have seen before, but the modulus operator is much less commonly used. Actually, it is commonly used, but it known under a different name, the remainder. Nine divided by four gives a remainder of one, so therefore 9%4 (pronounced "9 mod 4") evaluates to 1.


When more than one of the operators are used at once, for example:
When more than one of the operators are used at once, for example: