This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Errors, Help on Jcreator?! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Errors, Help on Jcreator?!" Watch "Errors, Help on Jcreator?!" New topic
Author

Errors, Help on Jcreator?!

Nadine Ernest
Greenhorn

Joined: Dec 10, 2008
Posts: 27
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!!


What Doesn't Kill You, Makes You Stronger!
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39478
    
  28
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

Joined: Dec 10, 2008
Posts: 27
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
Sheriff

Joined: Sep 28, 2004
Posts: 18914
    
  40

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


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39478
    
  28
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

Joined: Dec 10, 2008
Posts: 27
By"reference manipulation" i mean that i cannot say:

same with

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39478
    
  28
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

Joined: Dec 10, 2008
Posts: 27
Oh yeah you're right!!
i got it!!

thanks a lot campbell ritchie!!
you ve been great help!
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39478
    
  28
You're welcome
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Errors, Help on Jcreator?!