Java Arithmetic Operator compound operator result

Question

What is the output of the following code?


public class Main { 

  public static void main(String[] args) { 

    int i = 10; //from   w  ww .java  2s. co  m

    i += 2; 

    i -= 5; 

    i *= 6; 

    System.out.println(i); 

    System.out.println(i += 3); 

    System.out.println(i /= 2); 

  } 

} 


42
45
22



PreviousNext

Related