java increment / decrement operators

Note: python does not

A, increment operator

1, when used alone, the purpose of obtaining the value of the variable, the front and rear ++ ++ no difference, a value is incremented after use.

2, when used in combination, have the distinction. ++ ago, the first increase after use. After ++, after the first with a plus

Second, the decrement operator

Ditto

example:

public class test{
    public static void main(String[] args){
        int num = 10;
        int num2 = 20;
        int num3 = --num * num2++;
        System.out.println(num3); // 180 
        System.out.println(num); // 9 
        System.out.println(num2); // 21 
    }
}

Note: Generally not so with

Guess you like

Origin www.cnblogs.com/wt7018/p/12153401.html