-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNode.java
More file actions
35 lines (28 loc) · 904 Bytes
/
Node.java
File metadata and controls
35 lines (28 loc) · 904 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
28
29
30
31
32
33
34
35
// use generic because Node might need to take different data types
// but in this program it will probably always just be a String
public class Node<T> {
// the node that will come after this one
private Node<T> next;
private T data;
public Node(T data, Node<T> next){
this.data = data;
this.next = next;
} // end constructor
public T getData(){
return this.data;
} // end getData
public void setData(T data){
this.data = data;
} // end setData
public void setNext(Node<T> next){
this.next = next;
} // end setNext
public Node<T> getNext(){
return this.next;
} // end getNext
public static void main(String[] args){
Node<String> n = new Node<String>("V0", null);
// getData may not always return String
System.out.println(n.getData());
} // end main
} // end Node