Results 1 to 5 of 5
- 06-05-2012, 05:48 PM #1
Member
- Join Date
- Jun 2012
- Posts
- 3
- Rep Power
- 0
Another cannot find symbol variable thread
Good afternoon,
My assignment is due tonight, and Im running into some problems with the Java compiler. This is my code:
public class DoublyLinkedList<T> implements SimpleList<T> {
protected Node dummy;
protected int n;
public DoublyLinkedList() {
dummy = new Node();
dummy.next = dummy;
dummy.pre = dummy;
n = 0;
throw new NotYetImplementedException();
}
public void addFirst(T o) { throw new NotYetImplementedException(); }
public void addLast(T o) { throw new NotYetImplementedException(); }
public void add(int index, T element){ throw new NotYetImplementedException(); }
public T getFirst() { throw new NotYetImplementedException(); }
public T getLast() { throw new NotYetImplementedException(); }
public T get(int index) { throw new NotYetImplementedException(); }
public void clear() { throw new NotYetImplementedException(); }
public T remove(int index){ throw new NotYetImplementedException(); }
public boolean remove(Object o){ throw new NotYetImplementedException(); }
public T removeFirst() { throw new NotYetImplementedException(); }
public T removeLast() { throw new NotYetImplementedException(); }
public T set(int index, T element){ throw new NotYetImplementedException(); }
public int size() { throw new NotYetImplementedException(); }
public boolean contains(Object o){ throw new NotYetImplementedException(); }
public int indexOf(Object o){ throw new NotYetImplementedException(); }
}
public class Node<T> {
public Node() {
Node pre;
Node next;
T data;
}
}
I want to use a dummy node in my implementation of the Doubly Linked List, so it will be easier to code all the methods I need to write.
I keep on getting a problem with line 14 and 15:
dummy.next = dummy;
dummy.pre = dummy;
// cannot find symbol variable next (compiler error)
// cannot find symbol variable pre
I haven't programmed for a while, I know I made some newbie mistake. Thanks in advance,
Mark.
- 06-05-2012, 05:56 PM #2
Senior Member
- Join Date
- Jun 2007
- Location
- Bali, Indonesia
- Posts
- 697
- Rep Power
- 6
Re: Another cannot find symbol variable thread
You've declared the next and pre as local variable in the Node class constructor. So it won't available / accessible from outside the constructor.
Website: Learn Java by Examples
- 06-05-2012, 05:58 PM #3
Member
- Join Date
- Jun 2012
- Posts
- 3
- Rep Power
- 0
Re: Another cannot find symbol variable thread
I've changed the code of the Node class:
public class Node<T> {
public Node() {
Node pre;
Node next;
T data;
}
}
to
public class Node<T> {
Node pre;
Node next;
T data;
}
and it compiles now. I think that was the solution. Thanks for quick reply
- 06-05-2012, 06:45 PM #4
Member
- Join Date
- Jun 2012
- Posts
- 3
- Rep Power
- 0
Re: Another cannot find symbol variable thread
I have another little problem now:
public T getFirst() {
return dummy.next.data; //error on this line
}
returns an error like this: 'incompatible types'
This is the code for a Node:
public class Node<T> {
Node pre;
Node next;
T data;
}
Thanks in advance. Mark
- 06-05-2012, 08:15 PM #5
Re: Another cannot find symbol variable thread
Why do they call it rush hour when nothing moves? - Robin Williams
Similar Threads
-
Cannot find symbol variable
By xalebo in forum New To JavaReplies: 4Last Post: 11-28-2011, 07:09 PM -
Cannot find symbol variable Keyboard...
By Alnegar in forum New To JavaReplies: 6Last Post: 10-30-2010, 05:39 PM -
Java cannot find symbol- variable img
By crutchfieldj in forum New To JavaReplies: 3Last Post: 04-13-2010, 10:47 PM -
Cannot find symbol variable - Why? I can.. ^^
By Mattedatten in forum New To JavaReplies: 4Last Post: 03-08-2010, 07:07 PM -
Cannot find symbol variable pD! I cant fix it!!!
By Addez in forum New To JavaReplies: 2Last Post: 09-17-2009, 08:32 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks