title: Properly removing an Integer from a List<Integer>
body: <p>Here's a nice pitfall  I just encountered.
  Consider a list of integers:</p>
  
  <pre><code>List&lt;Integer&gt; list = new ArrayList&lt;Integer&gt;();
  list.add(5);
  list.add(6);
  list.add(7);
  list.add(1);
  </code></pre>
  
  <p>Any educated guess on what happens when you execute <code>list.remove(1)</code>? What about <code>list.remove(new Integer(1))</code>? This can cause some nasty bugs.</p>
  
  <p>What is the proper way to differentiate between <a href="http://download.oracle.com/javase/1.5.0/docs/api/java/util/List.html#remove(int)" rel="noreferrer"><code>remove(int index)</code></a>, which removes an element from given index and <a href="http://download.oracle.com/javase/1.5.0/docs/api/java/util/List.html#remove(java.lang.Object)" rel="noreferrer"><code>remove(Object o)</code></a>, which removes an element by reference, when dealing with lists of integers?</p>
  
  <hr>
  
  <p>The main point to consider here is the one <a href="https://stackoverflow.com/questions/4534146/properly-removing-an-integer-from-a-listinteger/4534152#4534152">@Nikita mentioned</a> - exact parameter matching takes precedence over auto-boxing.</p>