Is there difference between variable defined outside loop and inside loop?
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/407255/difference-between-declaring-variables-before-or-in-loop">Difference between declaring variables before or in loop?</a>  </p>
</blockquote>



<pre><code>String str;
for (int i = 0; i &lt; 10; i++) {
    str = "Hello, World"; // Is str created only 1 time?
}
</code></pre>

<p>What is difference between above and below?
And if they are different, which one is better?</p>

<pre><code>for (int i = 0; i &lt; 10; i++) {
    String str = "Hello, World"; // Is str created 10 times?
}
</code></pre>
