int index = 0; its initial value is 0 not garbage I am switching from 0 to 1 thats what is written in there.