Difference between pre-increment and post-increment in a loop?

后端 未结 22 1794
暗喜
暗喜 2020-11-21 23:41

Is there a difference in ++i and i++ in a for loop? Is it simply a syntax thing?

22条回答
  •  一整个雨季
    2020-11-22 00:36

    i++ ; ++i ; both are similar as they are not used in an expression.

    class A {
    
         public static void main (String []args) {
    
         int j = 0 ;
         int k = 0 ;
         ++j;
         k++;
        System.out.println(k+" "+j);
    
    }}
    
    prints out :  1 1
    

提交回复
热议问题