javacodex.com
Java Examples
Java Examples
memu home questions

Post Decrement

This java program example demonstrates the use of the unary operator post decrement.

Source: (PostDecrement.java)

public class PostDecrement {
   public static void main(String[] args) {
      int x = 5;
      System.out.println("x = " + x );
      System.out.println("x = " + x-- );
      System.out.println("x = " + x );
   }
}
 

Output:

# java PostDecrement 
x = 5
x = 5
x = 4

Contact: javacodex@yahoo.com