title: android - java - WeakReferences with an ArrayList?
body: <p>I know that with a <code>WeakReference</code>, if I make a <code>WeakReference</code> to something that unless there's a direct reference to it that it will be Garbage Collected with the next GC cycle. My question becomes, what if I make an <code>ArrayList</code> of <code>WeakReference</code>s?</p>
  
  <p>For example:</p>
  
  <pre><code>ArrayList&lt;WeakReference&lt;String&gt;&gt; exArrayList;
  exArrayList = new ArrayList&lt;WeakReference&lt;String&gt;&gt;();
  exArrayList.add(new WeakReference&lt;String&gt;("Hello"));
  </code></pre>
  
  <p>I can now access the data with <code>exArrayList.get(0).get()</code>.</p>
  
  <p>My question becomes: This is <code>WeakReference</code> data, will the data located at <code>exArrayList.get(0)</code> be GC'd with the next GC cycle? (even IF I don't make another direct reference to it) or will this particular reference stick around until the <code>arraylist</code> is emptied? (eg: <code>exArrayList.clear();</code>).</p>
  
  <p>If this is a duplicate I haven't found it with my keywords in google.</p>