Java Arithmetic Operator increment and decrement result 1

Question

What is the output of the following code?

public class Main { 

  public static void main(String[] args) { 

    int i = 10; // w w w  .j  a  v  a  2s. co m

    System.out.println(i++ ); 

    System.out.println(--i); 

    --i; 

    i--; 

    System.out.println(i); 

    System.out.println(++i); 

    System.out.println(i--); 

    System.out.println(i); 

    i++ ; 

    i = i++ + ++i; 

    System.out.println(i); 

    i = i++ + i++ ; 

    System.out.println(i); 

  } 

} 


10
10
8
9
9
8
20
41



PreviousNext

Related