When we use post or pre increment operator it increases the value.
Post increment operator (i++
) assigns the value first, then increments it. Pre increment operator (++i
) increments first then assigns the value.
They both behave like this :
int i=0;
i=i++;
System.out.println(i); //1
i=++i;
System.ou.println(i); //1