• Post Reply Bookmark Topic Watch Topic
  • New Topic

linked list/method question  RSS feed

 
Chris Brandt
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[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?
 
Chris Brandt
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
Steve McCann
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!