These operators date back to the days of C programming. These operators increment or decrement a variable by one. They're quite handy for using in expressions, because they will increment or decrement the variable after the expression has been tested.
A common example of their use is in for loops. Consider the following loop, which counts from one to ten.
for (int i=1; i<=10; i++) {
System.out.println (i);
}
In this case, the variable is incremented by one each time, until the terminating condition of greater than ten has been reached. It could just have easily been a while loop, or other expression.
SOURCE : www.referjava.com
No comments:
Post a Comment