javacodex.com
Java Examples
Java Examples
memu home questions

Pre Decrement

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

Source: (PreDecrement.java)

public class PreDecrement {
   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 PreDecrement 
x = 5
x = 4
x = 4

Contact: javacodex@yahoo.com