title: Best Practice for Returning Object References
body: <p>Consider this code snippet:</p>
  
  <pre><code>class MyClass{
      private List myList;
      //...
      public List getList(){
          return myList;
      }
  }
  </code></pre>
  
  <p>As Java passes object references by value, my understanding is that any object calling <code>getList()</code> will obtain a reference to <code>myList</code>, allowing it to modify <code>myList</code> despite it being <code>private</code>. Is that correct?</p>
  
  <p>And, if it is correct, should I be using </p>
  
  <pre><code>return new LinkedList(myList);
  </code></pre>
  
  <p>to create a copy and pass back a reference to the copy, rather than the original, in order to prevent unauthorised access to the list referenced by<code>myList</code>?</p>