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.
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.