Forums Register Login

linked list/method question

+Pie Number of slices to send: Send
I've defined a Linked List in my main method called LL. I've also defined several classes with their own methods. My problem is I want to use the predefined methods for Linked Lists within the methods that I define. This is where the problem occurs. I've posted one of my classes where an error occurs when compiled. It has no idea what LL is, I get the cannot resolve symbol error. I'm just wondering if there's a fix for this problem that I'm having.

+Pie Number of slices to send: Send
[Chris]: I've defined a Linked List in my main method called LL.

How? Is there some code somewhere in whatever class you're defining, which defines this "LL" thing? What does this code look like? What file is it in? Is that the same file that refers to "LL" later? And what is a Linked List, anyway? Is it similar to a LinkedList? Does the compiler have some way to know whether you're talking about a java.util.LinkedList or something else?
+Pie Number of slices to send: Send
 


How? Is there some code somewhere in whatever class you're defining, which defines this "LL" thing? What does this code look like? What file is it in? Is that the same file that refers to "LL" later? And what is a Linked List, anyway? Is it similar to a LinkedList? Does the compiler have some way to know whether you're talking about a java.util.LinkedList or something else?



I defined a LinkedList in my main method called LL.
"LinkedList LL = new LinkedList();"

This is all one file, I only posted a class where an error occurs. When I compile this, I get the cannot resolve symbol error because, in the method checkempty() it doesn't recognize what LL is when I use LL.size(). I guess my question could also be, how do I get it to recognize that LL is the LinkedList I defined in the main method. Sorry for the confusion.
+Pie Number of slices to send: Send
 

I defined a LinkedList in my main method called LL.
"LinkedList LL = new LinkedList();"


Sounds like LL is local to the main method and cannot be seen outside it. I think you have two choices - either make LL an instance variable or pass a reference to the checkEmpty() method. Of the two I would do the latter.

Just thought of something else - I would rename LL to something more meaningful and that followed the Java naming convention. This will help both you and others to read and understand your code later.

Steve
[ November 02, 2005: Message edited by: Steve McCann ]
If I'd had more time, I would have written a shorter letter. -T.S. Eliot such a short, tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 566 times.
Similar Threads
Override issue
Blank page in browser - "Response already committed" in logs
Generic Java, Type not bounded
ClassCastException in axis
Blank page in browser - "Response already committed" in logs
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 03:54:47.