How to allocate objects without saving them in variables?
<p>In my Java book there is an exercise that ask you to : "Allocate 10000 Rational objects without saving them in variables to they become garbage."</p>

<p>Is below the correct way to allocate objects without assigning them to varaibles? </p>

<pre><code>    for (int i = 0; i &lt; 10000; i++) {
        new Rational();
    }
</code></pre>

<p>Thanks</p>
