Jimbo99999
asked on
Java - Node class and LinkedList
Good Day Experts
I am relatively new to Java and am currently taking a course. Unfortunately, I am not finding much help in the book for the class. I am looking for a good tutorial on LinkedLists and the Node class as our assignment is as follows:
Put solution in a class called X, which uses the Node class to provide nodes for the linked list representation.
Can you all suggest some good reading matrial to help me get started?
Thanks,
jimbo99999
I am relatively new to Java and am currently taking a course. Unfortunately, I am not finding much help in the book for the class. I am looking for a good tutorial on LinkedLists and the Node class as our assignment is as follows:
Put solution in a class called X, which uses the Node class to provide nodes for the linked list representation.
Can you all suggest some good reading matrial to help me get started?
Thanks,
jimbo99999
More examples and tutorials:
Code example:
http://www.java-samples.com/showtutorial.php?tutorialid=347
and even YouTube lectures about LinkedLists (that seems longish, but fun):
http://www.youtube.com/watch?v=htzJdKoEmO0&feature=related
Code example:
http://www.java-samples.com/showtutorial.php?tutorialid=347
and even YouTube lectures about LinkedLists (that seems longish, but fun):
http://www.youtube.com/watch?v=htzJdKoEmO0&feature=related
ASKER
Thanks for the links.
If you don't mind me to ask a question about the requirement listing for the program:
"Put solution in a class called X, which uses the Node class to provide nodes for the linked list representation."
Would you think that means to add another class to my program when it says Node class?
Or does that just mean to do LinkedList.add to get nodes added to the LinkedList?
Thanks,
jimbo99999
If you don't mind me to ask a question about the requirement listing for the program:
"Put solution in a class called X, which uses the Node class to provide nodes for the linked list representation."
Would you think that means to add another class to my program when it says Node class?
Or does that just mean to do LinkedList.add to get nodes added to the LinkedList?
Thanks,
jimbo99999
I think if you look at the example
http://www.geekpedia.com/tutorial8_An-Introduction-to-Linked-Lists.html
you'll see that first snippet defines class Node for the LinkedList which
has set of integeres as the actual data.
The loose code which you see in all subsequernt snippets may in fact
be part of your class X.
Do they have any more specific requirements about
what should class X accomoplish?
If not ,this code which you see on this page
may well be the part of your class X, just add class declaration
and other formal stuff to it:
private static node firstNode; //a reference to the first node
private static node lastNode = null; //a reference to the last node
public static void display() //displays all the data in the nodes
{ node n=firstNode;
while(n!=null) //loops forward displaying node’s data (the integers)
{ System.out.print(n.getData
n=n.getNext(); //move to the next node in the list
}
}
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Thanks for the additional insight. The requirements are really rather straightforward...grab 2 large integers from keyboard input, parse apart by the commas, put each integer in a separate node in a linked list, turn the linked list back around and manipulate the large numbers before printing them out.
Conceptually I understand the LinkedList and nodes. But, man the book for the course is awful at explaining the Node class and how to work with it.
I will take a look at that first link again as you suggested and see what happens.
Thanks again,
jimbo99999
Conceptually I understand the LinkedList and nodes. But, man the book for the course is awful at explaining the Node class and how to work with it.
I will take a look at that first link again as you suggested and see what happens.
Thanks again,
jimbo99999
ASKER
Thanks for the help here as well.
jimbo99999
jimbo99999
I think there is a simple and short explanation:
http://www.geekpedia.com/tutorial8_An-Introduction-to-Linked-Lists.html