title: Java ArrayList remove object - IndexOutOfBoundsException
body: <p>I am trying to remove an object from an ArrayList, but I keep getting an IndexOutOfBounds Error. Now there is plenty information available why this happens when <strong>iterating</strong> over the ArrayList <strong>while removing</strong>, however I'm not doing that. 
  Example:</p>
  
  <pre><code> ArrayList&lt;Character&gt; a = new ArrayList&lt;Character&gt;();
   a.add('A');
   a.add('B');
   a.add('C');
   System.out.println(a);
   a.remove('A');
   System.out.println(a);
  </code></pre>
  
  <p>prints <code>[A, B, C]</code> and then fails with:</p>
  
  <pre><code>java.lang.IndexOutOfBoundsException: Index: 65, Size: 3
      at java.util.ArrayList.rangeCheck(ArrayList.java:635)
      at java.util.ArrayList.remove(ArrayList.java:474)
      at b.&lt;init&gt;(b.java:23)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
      at bluej.runtime.ExecServer$3.run(ExecServer.java:746)
  </code></pre>
  
  <p>Why is this happening?</p>
  
  <p><strong>EDIT to clarify this question is not a duplicate of <a href="https://stackoverflow.com/questions/32568261/how-to-avoid-java-lang-arrayindexoutofboundsexception">this question</a>:</strong></p>
  
  <p>The specific problem that is occuring here has nothing to do with the usual problems when removing elements while iterating. It is rather caused by the overloaded ArrayList <code>remove</code> method and the automatic type conversion from <code>char</code> to <code>int</code> by java.</p>
  
  <p>This aspect is not covered in the answer of the other question.</p>