Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * This is class Node. *important: data is stored as Object for this exercise
- *
- * @author MUHAMMAD AZRI JASNI
- * @version 10 OCTOBER 2012
- */
- public class Node
- {
- private Object data;//data carried by this node
- private Node link; // reference to the next node in chain or null if there's none
- /**
- * Constructor for objects of class Node
- */
- //I refer to http:://www.vias.org/javacourse/chap14_02.html
- //and http://www.mycstutorials.com/articles/data_structures/linkedlists
- public Node ()//default constructor
- {}
- public Node (Object data)
- {
- this.data = data;
- this.link = null;
- }
- public Node (Object data, Node link)//if we want to specify the node to point to.
- {
- this.data = data;
- this.link = link;
- }
- //methods: getData(), getLink(), setData(), setLink()
- public Object getData()
- {
- return data;
- }
- public void setData(int data)
- {
- this.data = data;
- }
- public Node getLink()
- {
- return link;
- }
- public void setLink(Node link)
- {
- this.link=link;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement