Question: So I was trying to produce an arraylist where the even indexes were all filled. Something like this [1, -, 1, -, 1, -........]. But it's giving me an index out of bounds error. Why is that?

```
import java.util.ArrayList;

class Main {
    public static void main(String[] args) {
        ArrayList<Integer> a = new ArrayList<>(10);

        for (int i=0; i<11; i+=2) {
            a.add(i, new Integer(1234));
        }
    }
}

```

Answer: 
Remember indices always start with 0.
You've created an arraylist with size 10, which means you should iterate through index 9, not 10.

Your for loop should be:

```
for (int i = 0; i < 10; i += 2)

```
Arrays use zero based indexing meaning you can reference a[0] through a[9]. so your constraint in the for loop
Should be i < 10. I’ll edit this answer and give more detail when I get home.