In the first (commented out) case you are not incrementing 'i', you are simply assigning the value of i+5 to the i'th entry in the array.
In the second (failing) case you are incrementing i by 5 and assigning that value to the pre-increment i'th entry.
Then, when you attempt to print out the value, i will eventually be beyond the size of the array and *bang*.
You are iterating the whole of the array, so you want array.length. Remember that the < operator will stop the loop before you get to array.length. If you have a 10‑element array, the loop will stop after index 9.