There are two types of addition and subtraction operators, preface and postfix, each with different behavior.
--In the case of postscript Calculate after doing something
b = a++;
// b = a;
// a = a + 1;
//Same as
--Introduction Do something after calculating
b = ++a;
// a = a + 1;
// b = a;
//Same as
For example, when used in print ()
--After: Calculate after output --Before: Calculate and then output
become.
operator.java
public class operator{
public static void main(String[], args){
i = 5;
countdown1(i); // 54321
System.out.println();
i = 5;
countdown2(i); // 43210
}
void countdown1(int i){
for(i > 0){
System.out.print(i--); //Output and then subtract
countdown1(i);
}
}
void countdown2(int i){
for(i > 0){
System.out.print(--i); //Subtract and then output
countdown2(i);
}
}
}