class Trickytest {
public static void main (
String args [ ] ) {
int i = 10 ; // line 1
i = ++i ; // line 2
System.out.println("After 1st increment: "+i);
i = i++ ;
System.out.println("After 2nd increment: "+i);
i=i++;
System.out.println("After 3rd increment: "+i);
i=i++;
System.out.println("After 4th increment: "+i);
i=i++;
System.out.println("After 5th increment: "+i);
System.out.println ("value of "+ i ); // line 4
}
}
This prints value of i 11 each time ,i know i++ first assigns value and then increment i & ++i first assign and then increment i.But i need explanation because if i use j=i++;it prints incremented value..