permaculture playing cards
The moose likes Java in General and the fly likes A challenge Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "A challenge" Watch "A challenge" New topic

A challenge

Remo Fernandez

Joined: Feb 18, 2004
Posts: 18
I hav a linkedlist problom.i hav tried a lot to resolve it.but i cant.
this linked list allowing new elements to be added to the front and deleted from the can it be modified so that it adds elements to the end of the list rather than the front of the list?.
that means,
when i run this program,if i input 3 Strings as "aa","bb","cc",the current output will be,
i want to change the program so it prints,
it can be done by adding elements to the end of the list rather than the front of the list.anyone can do it??.here's the hint.
HINT one way is to store a Reference to the last element of the list and use it to access the end of the list. The other way is to traverse from the front to the last node in a similar way to traverse, then once there create a new node and put a reference to it from the last node. You will also need to be careful about the case when you are adding to an empty list.
Julie Hay

Joined: Nov 26, 2003
Posts: 4
Is this homework or something you are doing in your spare time just curious? it seems you need to turn you linked list into a double linked list. Each node should have a message, nextNode, and previousNode. Plus a refrence to the last node, and another method to print using previousNode and not nextNode.

Julie<br />Dream a little dream...Then go get it. Little dreams make a BIG dream a reality.
Jessica Sant

Joined: Oct 17, 2001
Posts: 4313

moving this to Java in General (Intermediate) seeing as though you're trying to create your own linked list and play with it rather than asking questions about the java.util.LinkedList class that you'd be tested on in the Certification exam.
Please continue the conversation there.

- Jess
Blog:KnitClimbJava | Twitter: jsant | Ravelry: wingedsheep
Billybob Marshall
Ranch Hand

Joined: Jan 27, 2004
Posts: 202
Jessica, while I know why you zapped my (flame) response, it's ironic that you wouldn't instead just zap this whole obvious homework thread, which he/she posted in 4 separate forums (so far)
[ February 19, 2004: Message edited by: Billybob Marshall ]
Jessica Sant

Joined: Oct 17, 2001
Posts: 4313

I didn't zap any of your posts -- someone else must have. I didn't realize this had been posted in muultiple forums, thanks for letting me know.
Please don't post the same question in multiple forums, it wastes people's times and makes the conversation difficult to follow.
As for your homework. Here at the Javaranch, we're more than happy to help you with any specific questions you have, but we won't do your homework for you. That you need to do on your own.
Please continue the conversation in the original thread here.
I agree. Here's the link:
subject: A challenge
It's not a secret anymore!