title: Having two stores of an object in Java
body: <p>Suppose I have the following code in java</p>
  
  <pre><code>Object object = new Object();
  mylist.add(object);
  mylist2.add(object);
  </code></pre>
  
  <p>As far as I understand I have created one object in memory and both <code>mylist</code> and <code>mylist2</code> have some kind reference to this object. Is that correct? </p>
  
  <p>In which case how much more memory does the program above use compared to if I had just done</p>
  
  <pre><code>Object object = new Object();
  mylist.add(object);
  </code></pre>
  
  <p>I'm wondering because I sometimes feel it would be useful to have two <strong>different</strong> data structures holding the <strong>same</strong> information for different purposes. </p>
  
  <p>Ex:<br>
  <em>A binary tree and a hash map such that you can easily search for objects in constant time and easily iterate through an ordered list of the objects.</em></p>