java.lang.ArrayIndexOutOfBoundsException when adding new elements to an array? : <p>I have the following <code>Java</code> class that adds a Person object to an existing Person <code>Array</code>:</p>

<pre><code> public class PersonService{

 protected int lastItemInPersonArray = 0;

 private Person[] persons = new Person[100];


 public void addPersonToPersonArray(Person personToAdd){

        persons[lastItemInPersonArray++] = personToAdd;

    }

}
</code></pre>

<p>I can add 1 object correctly here but when I try to 2 I get the following error:</p>

<pre><code>java.lang.ArrayIndexOutOfBoundsException: 1
</code></pre>

<p>What is incorrect with my logic that is causing this?</p>
