JAVA PROGRAMS
👉 Program below shows the basic difference between Post/Pre increment and decrement :
class unoperator
{
public static void main(String args[])
{
int a = 20;
System.out.println(a++);
System.out.println(a--);
System.out.println(++a);
System.out.println(--a);
}
}
OUTPUT
Explanation:
The number which we have : 20
now...
(a++) time (a--) time
21 only in a memory not displaying the output 21 →→→ Now we have 21 that is
updated value in a memory so it will print 21 and →→ in a memory decrements the number from 21
(++a) time
to 20 →→→Now we have 20 in a memory so it will increment the value and then print the
incremented value →→from 20 after increment it will print 21 and store this number in a memory
(--a) time
→→→Now we have 21 in a memory so it will decrement the value and then print the decremented
value →→from 21 after decrement it will print 20 and store this number in a memory .