javacodex.com
Java Examples
Java Examples
memu home questions

Pre Increment

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

Source: (PreIncrement.java)

public class PreIncrement {
   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 PreIncrement 
x = 5
x = 6
x = 6

Contact: javacodex@yahoo.com