The default value of int in java is zero. Therefore your int array is initialized to zero in all of it's indexes. During the first iteration of your loop the following are your variable states...
myArray = [0, 0, 0, 0, 0, 0];
i = 0;
the value of i is 0 therefore zero is inserted into myArray[0]. Then i is incremented. now you are printing the value of myArray[1]
which is '0'. At the end of the loop the following is the state of your variable...
myArray = [0, 0, 0, 0, 0, 0];
i = 1;
now the value of i is incremented by for loop and the value of i becomes 2. now you are inserting the value of 2 is myArray[2]
. and then the value of i is incremented because of post increment operator. After the loop executes this is the state of your variables.
myArray = [0, 0, 2, 0, 0, 0];
i = 3;
now the value of i is incremented by for loop and the value of i becomes 4.now you are inserting the value of 4 is myArray[4]. and then the value of i is incremented because of post increment operator. After the loop executes this is the state of your variables.
myArray = [0, 0, 2, 0, 4, 0];
i = 5;
now the value of i is incremented and the condition of for loop is broken. then you print the value of the array... which output's the following data...
Outside for[0, 0, 2, 0, 4, 0]
because of the post increment operation your value of myArray always prints the value of the next position. As the default value of int is zero you always get zero printed in your output.
if you remove the post increment operation i think you'll find what you were trying. and the following link provides how increment works in java...
link
here is a link on how to debug an application using eclipse IDE...
link