-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNode.java
69 lines (61 loc) · 1.49 KB
/
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package sll;
/**
* A node is represented in this singly-linked list.
* It keeps a reference to the next node as well as a string data value.
*/
public class Node {
private String data;
private Node next;
/**
* Creates a new node with Null fields and the next references.
*/
public Node() {}
/**
*
* The string information to be saved in the node
*/
public Node(String data) {
this();
this.data = data;
}
/**
* Brings back the string information kept in the node.
*
* also @return data present in the string
*/
public String getData() {
return data;
}
/**
* sets the provided value in the string data.
*
* new string information to be kept in the node
*/
public void setData(String data) {
this.data = data;
}
/**
* Returns the next node's reference back.
*
* Reference that @return to next node
*/
public Node getNext() {
return next;
}
/**
* sets the provided node as the reference for the following node.
*
* n is the reference of the next node
*/
public void setNext(Node n) {
this.next = n;
}
/**
* A data from the node represented as a string.
*
* illustrating a string the data that @return
*/
public String toString() {
return data;
}
}