is these code cause memory leak in java?
<pre><code>    ArrayList&lt;Object&gt; list = new ArrayList&lt;Object&gt;();
    for (int i = 0; i &lt; 10; i++) {
        Object o = new Object();
        list.add(o);
    }
    list = null;
</code></pre>

<p>or</p>

<pre><code>    ArrayList&lt;Object&gt; list = new ArrayList&lt;Object&gt;();
    for (int i = 0; i &lt; 10; i++) {
        Object o = new Object();
        list.add(o);
        o = null;
    }
</code></pre>

<p>which code block will cause memory leak in java, why?</p>

<p>If neither will cause memory leak, how can I cause a memory leak~ (I want some code)</p>
