Here is a Java Program to Demonstrate the Use of Pre and Post Operator.
Output of Above Java Program:
The value is 50.
The value of i++ is 50.
The value of ++i is 52.
The value of ++i is 53.
1 2 3 4 5 6 7 8 9 | class prepost { public static void main(String args[]){ int i= 50 ; System.out.println( "The value is " +i + "." ); System.out.println( "The value of i++ is " + i++ + "." ); System.out.println( "The value of ++i is " + ++i + "." ); System.out.println( "The value of ++i is " + ++i + "." ); } } |
Output of Above Java Program:
The value is 50.
The value of i++ is 50.
The value of ++i is 52.
The value of ++i is 53.