Re-using variable name to ref. object in a loop...come out of loop...where is my object?
<p>Could anyone explain why this won't compile? This loop keeps moving the ref. 'person' to a newly created object, which seems to work fine. The last line read in from a file should, at the end of the loop, be referenced by 'person' and it's methods should be accessible outside this loop, right?</p>

<pre><code>while ((line = file.readLine()) != null) {
    Person person = new Person(line);
    //do
}
System.out.println(person.getSmoker());
</code></pre>

<p>Compiler output:</p>

<pre><code>Query.java:29: cannot find symbol
symbol  : variable person
location: class Query
            System.out.println(person.getSmoker());
                               ^
</code></pre>

<p>The answer must be no, but I can't figure out why (and I thought my object/heap etc. understanding was getting somewhere)</p>

<p>Thanks for your help</p>
