wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Linked List Remove? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Linked List Remove?" Watch "Linked List Remove?" New topic
Author

Linked List Remove?

Luke Gotto
Greenhorn

Joined: Apr 04, 2008
Posts: 2
When i run this it removes all of the elemets of the list except the last one... Any ideas why it is not geting to the last node?

public E remove() // delete link with given key
{
E tmp;
tmp = null;
cursor = first;
previous = first;


if (cursor == null)
return null;
else
tmp = first.item;
previous = cursor;
first = cursor.next;
length = length -1;

return tmp;


}
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Sorry, I really can't figure out how this is intended to work. I think it might help if you explained the steps in English. It's a good way to check your own logic, and it would give us a clear idea of what you're expecting to happen.

(Code Tags with clean indentation would also help.)


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Linked List Remove?
 
Similar Threads
Need help to convert from Con List to Link List
Iterator Pattern
[resolved] Problem with generic methods
really weird linked list error, please help!!
Generics: cannot make a static reference to the non-static type