-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNode.java
More file actions
27 lines (22 loc) · 680 Bytes
/
Copy pathNode.java
File metadata and controls
27 lines (22 loc) · 680 Bytes
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
public class Node<E> {
private E data; // what this node is actually holding
private Node<E> next; // when it comes to variable declaration that is not a primitive, Java treats this kind of declaration as a reference
// constructor
// Node<E> is already implied, even though it is not defined as so in the constructor
public Node(E data, Node<E> next) {
setData(data);
setNext(next);
}
public void setData(E data) {
this.data = data;
}
public void setNext(Node<E> next) {
this.next = next;
}
public E getData() {
return data;
}
public Node<E> getNext() {
return next;
}
}