Enhanced For Loop not changing all elements of my array : <p>I am currently working on a program that will roll 5 dice and store a random number for each dice in an array.
My problem is my method is only changing the first element and leaving the rest of the elements as 0's. (Only rolling the first dice so to say)</p>

<p>I initialized an array with 5 values, then run this method which takes an array as a parameter, checks if an element is 0, if it is it assigns a random value between 1 and 6.</p>

<p>I've tried doing an enhanced for loop that looks at each element in the array, and theoretically if it is zero, it assigns a random integer between 1 to 6 to it.</p>

<pre><code>public static void rollDice(int[] dice) {

for (int element: dice) {
    int roll = (int)(Math.random()*6) + 1;

    if (element == 0) {
        dice[element] = roll;
    }
}
</code></pre>

<p>My results are currently: [Random Number, 0, 0, 0, 0]
My expected results are: [5 random integers]</p>
