I am new to java. Wanted help to analyse small bit of code as below. Below code prints value of 'i' as 0 always. It seems like 'i' never gets incremented and below for loop results in infinite loop. Can some one explain why 'i' is not getting incremented at all? I know when a post increment operator is used, the expression value is first used and then the value gets incremented. So, first iteration of the loop will print value of 'i' as 0. But, at least in second iteration, 'i' should have been incremented to 1 and so on. Right?:
public class PostIncExample {
public static void main(String[] args) {
for(int i=0; i<10;){
System.out.println(i);
i=i++;
System.out.println("hi" + i);
}
}
}