-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNode.java
More file actions
64 lines (60 loc) · 1.22 KB
/
Copy pathNode.java
File metadata and controls
64 lines (60 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/**
* Node class for linked list
* @author Wei Zhong Tee
* @since 8 May 2020
*/
public class Node<E> {
private E element; // Value for this node
private Node<E> next; // reference to next node in list
/** Constructor
* @param item the element to be stored in Node
* @param nextVal the next Node that this is pointing to
*/
public Node(E item, Node<E> nextval)
{
element = item;
next = nextval;
}
/** Constructor
* @param item the element to be stored in Node
*/
public Node(E item){
element = item;
next = null;
}
//other constructors
public Node(){
element = null;
next = null;
}
public Node(Node<E> nextval) {
next = nextval;
}
/**
*@return the Node that is next to this
*/
public Node<E> getNext() {
return next;
}
/**
* Sets this next to the given Node
* @param nextNal the Node that is to be set to this Node's next
*/
public void setNext(Node<E> nextval){
next = nextval;
}
/**
* returns the element in the Node
*@return element in the Node
*/
public E getElement() {
return element;
}
/**
* sets the element stored in Node to the element given
*@param item the element to be stored in Node.
*/
public E setElement(E item) {
return element = item;
}
}