Field member error
<p>Okay, I might be going crazy but I've never encountered this error before.</p>

<p>This doesn't compile:</p>

<p>The error I get is : "Cannot find symbol variable visited" </p>

<p><strong>EDITED</strong></p>

<p>Here's the whole function:</p>

<pre><code>public void depthFirstTraverse(Node startNode) {
    Stack&lt;Node&gt; myStack = new Stack&lt;Node&gt;();
    myStack.push(startNode);

    while (!myStack.empty()) {
        Node top = myStack.pop();
        top.visited = true;
        System.out.println(top.item);
        for (int i = 0; i &lt; top.getAdjList().size() ; i++) {
            //Node temp = (Node)top.getAdjList().get(i);
            if (!(Node)top.getAdjList().get(i).visited) {
                myStack.push((Node)top.getAdjList().get(i));
            }
        }
        top.visited = false;
    }

}
</code></pre>

<p>This part doesn't work</p>

<pre><code>if (!top.getAdjList().get(i).visited) {  // this line gives me an error
</code></pre>

<p>This does:</p>

<pre><code>for (int i = 0; i &lt; top.getAdjList().size() ; i++) {
            Node temp = (Node)top.getAdjList().get(i);
            if (temp.visited) {
                myStack.push(temp);
            }
        }
</code></pre>

<p>Why is this so? </p>
