Operators in Java
Posted by
Ravi Kumar at Thursday, March 5, 2009
Share this post:
|
0 Comments
The arithmetic operators +, –, *, / are used in Java for addition, subtraction, multiplication, and division. The / operator denotes integer division if both arguments are integers, and floating-point division otherwise.
Integer remainder (that is, the mod function) is denoted by %. For example, 17/2 is 8, 17%2 is 1, and 17.0/2 is 8.5.
Example:
int n = 5;
int a = 2 * n; // a is 10
In java x += 4; is equivalent to x = x + 4;