Increment and Decrement Operators : Arithmetic Operators « Language Basics « Java






Increment and Decrement Operators

 

public class Main {
  public static void main(String[] args) {

    int i = 10;
    int j = 10;
    i++;
    j++;

    System.out.println("i = " + i);
    System.out.println("j = " + j);

    int k = i++;
    int l = ++j;

    System.out.println("k = " + k);
    System.out.println("l = " + l);
  }
}
/*
i = 11
j = 11
k = 11
l = 12
*/

   
  








Related examples in the same category

1.Arithmetic Operators Example
2.Arithmatic Assignment Operators