title: Java ArrayList search and remove
body: <p>I am attempting to search through an array list to find a value (which may reoccur) and remove all instances of that value. I also would like to remove from a separate array list, values that are at the same location. Both ArrayLists are <code>ArrayList&lt;String&gt;</code>.</p>
  
  <p>For example I am looking for the number 5 in ArrayList2:</p>
  
  <pre><code>ArrayList 1       ArrayList2
  cat               1
  pig               2
  dog               5
  chicken           3
  wolf              5
  </code></pre>
  
  <p>Once I find the number 5, in both locations, I would like to remove dog and wolf from ArrayList1. My code has no errors but it doesn't seem to be actually removing what I am asking it. </p>
  
  <pre><code>//searching for
  String s="5";
  //for the size of the arraylist
  for(int p=0; p&lt;ArrayList2.size(); p++){
   //if the arraylist has th value of s
   if(ArrayList2.get(p).contains(s)){
     //get the one to remove
     String removethis=ArrayList2.get(p);
     String removetoo=ArrayList1.get(p);
     //remove them
     ArrayList2.remove(removethis);
     ArrayList1.remove(removetoo);
    }
  }
  </code></pre>
  
  <p>When I print the arrayLists they look largely unchanged. Anyone see what I am doing wrong? </p>