title: Pass by Value (Queue) in Java gives an unexpected output
body: <p>I have a very small program: </p>
  
  <pre><code>    public static void main(String[] args) {
  
  Queue&lt;String&gt; queue = new LinkedList&lt;String&gt;();
  queue.add("one");
  queue.add("two");
  queue.add("tree");
  
  printQueue(queue);
  customizeQueue(queue);
  printQueue(queue);
  }
  
  private static void customizeQueue(Queue&lt;String&gt; queue) {
  queue.add("four");
  queue.add("five");
  printQueue(queue);
  }
  
  private static void printQueue(Queue&lt;String&gt; queue) {
  for(String s: queue){
      System.out.print(s + " ");
  }
  System.out.println();
  }
  </code></pre>
  
  <p>I'm expecting an output of: </p>
  
  <pre><code>one two tree
  one two tree four five
  one two tree
  </code></pre>
  
  <p>However I'm getting:</p>
  
  <pre><code>one two tree
  one two tree four five
  one two tree four five
  </code></pre>
  
  <p>I'm not sure why this is happening. Am I passing the reference of the LinkedList instance? Can somebody please clarify why I'm not getting my expected output. </p>