Understand Arraylist IndexOutOfBoundsException in Android <p>I get a lot of <code>IndexOutOfBoundsException</code> from the any <code>Arraylist</code> I use. Most of the times it works fine but sometimes I get this annoying error on <code>Arraylists</code> i use on my project.</p> <p>The main cause is always either</p> <pre><code>java.util.ArrayList.throwIndexOutOfBoundsException: Invalid index 3, size is 3 </code></pre> <p>or</p> <pre><code>java.util.ArrayList.throwIndexOutOfBoundsException: Invalid index 0, size is 0 </code></pre> <p>Help me understand the main cause of this error as no matter how many answers I've searched they don't completely help me.</p>