Java: can not find a variable after its definition

advertisements

I am trying to create a dummy Node that allows me to traverse a LinkedList object that I have created, beginning at that LinkedList's .first Node and continuing until it has no more values. The problem that I am having, specifically, is that when I create a dummy Node, Java doesn't recognize the variable which I have just used to define my dummy Node. Observe in the following code:

private MyLinkedList extract(int x){
MyLinkedList values = new MyLinkedList();
for(int i = 0; i < x; i++){
  Node p = table[i].first;
  while(table[i].p != null){
    values.add(p.value);
    p = p.next;
  }
}
return values;
}

The error arises in the while loop booelan statement and I am told that Java "cannot find symbol : variable p"

Any idea why? Thanks!

Some variable definitions for your convenience:

table = hashtable of MyLinkedLists;

x = size of hashtable;


Node p = table[i].first;
  while(table[i].p != null){
    values.add(p.value);
    p = p.next;
  }

unless the return value of table[i] contains a variable p , you can't use it