Java Method Pass-by-Value Issue
<p>When I call my <code>bar(Map map)</code> method from my current <code>foo(...)</code> method, I run into the following behavior where bar() says that map is empty.</p>

<pre><code>private void foo() {
  Map map = new Map(); // pseudocode
  // add (key, value)'s to map
  printMap(map); // prints key and values
  Map newMap = bar(map);
  ...
  System.out.println(newMap.size()); // returns 0  
} // end foo();

private Map bar(Map map) {
  printMap(map); // return empty
  ...
}
</code></pre>

<p><strong>EDIT</strong>: Could it have been this print method's <code>it.remove()</code>call ? When I removed this call, I no longer had a problem.</p>

<pre><code>private void printMap(Map mp) {
    Iterator it = mp.entrySet().iterator();
    while (it.hasNext()) {
        Map.Entry pairs = (Map.Entry)it.next();
        logger.info(pairs.getKey() + " = " + pairs.getValue());
        it.remove(); // avoids a ConcurrentModificationException
    }
}
</code></pre>
