title: remove a string from an array list
body: <p>I keep getting this error:</p>
  
  <blockquote>
    <p>java.lang.IndexOutOfBoundsException: Index: 3, Size: 3</p>
  </blockquote>
  
  <p>I am trying to remove the string "Meg", and it will compile, but I keep getting this error. </p>
  
  <pre><code>import java.util.ArrayList;
  
  public class CustomerLister2 {
      public static void main (String[] args) {
  
          ArrayList&lt;String&gt; name = new ArrayList&lt;String&gt;();
  
          name.add("Chris");
          name.add("Lois");
          name.add("Meg");
          name.add("Meg");
          name.add("Brain");
          name.add("Peter");
          name.add("Stewie");
  
          for ( int i = 0;  i &lt; name.size(); i++){
              name.get(i);
              name.remove(i);
              name.set(i,"Meg");
          }
  
          for(String names: name){
              System.out.println(names);
          }
      }
  }
  </code></pre>