Java: Prefix/postfix of increment/decrement operators?

前端 未结 10 1426
不知归路
不知归路 2020-11-22 07:17

From the program below or here, why does the last call to System.out.println(i) print the value 7?

class PrePostDemo {
     public          


        
10条回答
  •  逝去的感伤
    2020-11-22 07:40

    System.out.println(i++);  // "6"
    

    This sends println the value I had prior to this line of code (6), and then increments I (to 7).

提交回复
热议问题