forked from reeucq/advanced-data-structures
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNode.java
44 lines (40 loc) · 1000 Bytes
/
Node.java
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
/**
* Node class for the linked list
* This class is used to create a node for the linked list
*/
public class Node {
/** data members */
Object data; // data of the node
Node next; // reference to the next node
/**
* Default Constructor
*/
public Node() {
this.data = null;
this.next = null;
}
/**
* This constructor creates a node with the given data
* and in the next field, it stores null
* @param data data of the node
*/
public Node(Object data) {
this.data = data;
this.next = null;
}
/**
* This constructor creates a node with the given data and next node
* @param data data of the node
* @param next reference to the next node
*/
public Node(Object data, Node next) {
this.data = data;
this.next = next;
}
/**
* This method returns a new node
*/
public static Node createNewNode() {
return new Node();
}
}