Math: +, -, *, and /
Now let's try arithmetic in Java. You can add, subtract, multiply, and divide numbers and store them in variables like this:
int sum = 34 + 113;
int difference = 91 - 205;
int product = 2 * 8;
int quotient = 45 / 3;
Math: %
Let's explore one more special math operator known as modulo.
- The modulo operator - represented in Java by the
% symbol - returns the remainder of dividing two numbers.
For example, 15 % 6 will return the value of 3, because that is the remainder left over after dividing 15 by 6.
java coding examples
ReplyDeletejava programming - Destroy a servlet session