Arithmatic Assignment Operators : Arithmetic Operators « Language Basics « Java






Arithmatic Assignment Operators

 


public class Main {
  public static void main(String[] args) {
    int i = 5;
    int j = 10;

    i += 5; // same as i = i + 5
    j -= 2; // same as j = j - 2

    System.out.println("i = " + i);
    System.out.println("j = " + j);
  }
}
/*
i = 10
j = 8
*/

   
  








Related examples in the same category

1.Arithmetic Operators Example
2.Increment and Decrement Operators