title: Java- passing Lists to methods working as pass by reference
body: <p>There are lot of discussions in stackoverflow regarding pass by value and pass by reference. But i want to know what is happening in the following scenario?
  This page says java is pass by value. <a href="https://stackoverflow.com/questions/40480/is-java-pass-by-reference-or-pass-by-value">Is Java &quot;pass-by-reference&quot; or &quot;pass-by-value&quot;?</a>.</p>
  
  <p>In case of following code, the the element is removed from the removeElement method , it is removing the 5th element from list when i print the list.</p>
  
  <pre><code>public class Load {
      public static void main(String[] args) {
  
  
          ArrayList&lt;Integer&gt; list = new ArrayList&lt;Integer&gt;();
          list.addAll(Arrays.asList(1,1,2,3,5,5,13,21));
          removeElement(list);
          System.out.println(list);
      }
          public static void removeElement(List&lt;Integer&gt; list){
              list.remove(5);//removes element at index 5
          }
  }
  </code></pre>
  
  <p>The output of the program is  <code>[1, 1, 2, 3, 5, 13, 21]</code>. </p>
  
  <p>Can somebody explain how this is pass by value rather than pass by reference?</p>