- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathListNode.java
More file actions
Latest commit
43 lines (36 loc) · 1.03 KB
/
Copy pathListNode.java
File metadata and controls
43 lines (36 loc) · 1.03 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
/*
* Name: Thomas Cheng
*
* Date: May 2, 2018
*
* Dsscription: This is the ListNode<T> class.
*/
publicclassListNode<T> {
privateTdata;
privateListNodenext;
// Constructor: No reference to next node provided so make it null
publicListNode( TnodeData ) {
this( nodeData, null);
}
// Constructor: Set data and reference to next node.
publicListNode( TnodeData, ListNodenodeNext ) {
data = nodeData;
next = nodeNext;
}
// Accessor: Return the data for current ListNode object
publicTgetData() {
returndata;
}
// Accessor: Return reference to next ListNode object
publicListNodegetNext() {
returnnext;
}
// Mutator: Set new data for current ListNode object
publicvoidsetData( TnewData ) {
data = newData;
}
// Mutator: Set new reference to the next node object
publicvoidsetNext( ListNodenewNext ) {
next = newNext;
}
}