Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Errors, Help on Jcreator?!

 
Nadine Ernest
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So this is my code:


Now, when i do compile with Jcreator, it gives me the following errors:

error 1: line 13, 16 , 18 ---> cannot find symbol variable result even though i declared it in line 26 as LinkList result = new LinkList();

*2nd request: i want the main method to display the result list and when i do so it only says process completed?!

SO please help me?!
Thank youu so much!!
 
Campbell Ritchie
Sheriff
Posts: 48910
58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have declared the result variable as a local variable in the main method. You should keep the main method as small as possible; the ideal is one statement.

And the local variables in the main method do not exist in any other methods, unless you pass a reference.
 
Nadine Ernest
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
heres the thing,
i cant use any reference manipulation so i really cant figure out a way to fix these errors!!
Help!!
 
Henry Wong
author
Marshal
Pie
Posts: 21112
78
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nadine Ernest wrote:heres the thing,
i cant use any reference manipulation so i really cant figure out a way to fix these errors!!
Help!!


What does this mean? What do you mean you can't do "reference manipulation"?

Henry
 
Campbell Ritchie
Sheriff
Posts: 48910
58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does "reference manipulation" mean?

You have a method which takes two Lists as its parameters and returns a List which you aren't using. You need to declare the result List in the method, then you have another local variable. And you need to use whatever that method returns. So you need to work out how to put those two together. And also how to get rid of the infinite recursion in the union method.

Don't use the == operator to test whether the members of the two Lists are equal to each other. Use their equals() method. Every Object has an equals() method.
It is unlikely that you will have access to a data field of the contents of your Lists. You ought to make whichever type you are putting into the Lists implement the Comparable interface, then use its compareTo() method. You might be able to say List<Comparable> but I am not quite sure about that.

You will have to look very carefully at the "if-elses" and go through them with a pencil and paper; what will happen if a == b, what will happen if a < b and what will happen if a > b.
 
Nadine Ernest
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By"reference manipulation" i mean that i cannot say:

same with

 
Campbell Ritchie
Sheriff
Posts: 48910
58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
List1.first? That suggests you haven't got your fields labelled private as they ought to be. You should be writing list1.getFirst(), or list1.removeFirst() as you did earlier.

"Reference manipulation" (as you will have seen from the comments yesterday) is not a phrase we are familiar with.
 
Nadine Ernest
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh yeah you're right!!
i got it!!

thanks a lot campbell ritchie!!
you ve been great help!
 
Campbell Ritchie
Sheriff
Posts: 48910
58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic