Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

📚 The CoCalc Library - books, templates and other resources

132939 views
License: OTHER
1
public class Node<E> {
2
private final E element;
3
private Node<E> next;
4
5
/**
6
* Constructor.
7
*
8
* @param element the element you want to add
9
*/
10
public Node(E element) {
11
this.element = element;
12
}
13
14
/**
15
* Getter for the content of this node.
16
*
17
* @return the element
18
*/
19
public E getElement() {
20
return element;
21
}
22
23
/**
24
* @return the next
25
*/
26
public Node<E> getNext() {
27
return next;
28
}
29
30
/**
31
* @param next the next to set
32
*/
33
public void setNext(Node<E> next) {
34
this.next = next;
35
}
36
37
/*
38
* (non-Javadoc)
39
*
40
* @see java.lang.Object#toString()
41
*/
42
@Override
43
public String toString() {
44
return "Node[element=" + element + "]";
45
}
46
}
47
48