Consider:
int[] aryNums=new int[5];
for (int i=0; i<=5; i++)
{
aryNums[i] = i++;
System.out.println(aryNums[i]);
}
Why doesn't this give me the values in the array as 1, 2, 3, 4, 5? Instead, it gives an exception like 0,0 and error.
And also if I change
aryNums[i] = i++; \to
aryNums[i] = i+1;
I get the value {1,2,3,4,5} in the array. What is the diff between i++ and i+1 here?